Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Resume a command


Reply
 
Thread Tools Display Modes
  #1  
Old 12-29-2004, 09:23 AM
coolmision coolmision is offline
Regular
 
Join Date: Dec 2003
Posts: 71
Unhappy Resume a command


hello,

I have a small issue when I'm trying to realize smthg like this:

Code:
TEST: If MsgBox("Open a window?", vbYesNo + vbQuestion, "Question") = vbYes Then frmtest.Show Else frmtest.show.text = "bla" TEST2: If MsgBox("Do you want to edit the value?", vbYesNo + vbQuestion, "Question") = vbYes Then frmtest2.Show .....

Now, my problem is that as soon as a user clicks on yes in the msgbox, a new form will appear and he will enter a form manually, then press a button. What I want to know now is, if it is possible to tell the program to resume at TEST2: when clicking on the button in another form? (as in resuming that code)

Thanks in advance

~cm
__________________
www.gamers2k4.com
Reply With Quote
  #2  
Old 12-29-2004, 09:28 AM
robertg's Avatar
robertg robertg is offline
Privileges Suspended
 
Join Date: Dec 2004
Location: Sterling Heights, MI
Posts: 520
Default

Instead of having all the code in one routine, separate them into Public Subs on your form. Then, from the second form, you can call whatever routine you want the user to go through next.
Reply With Quote
  #3  
Old 12-29-2004, 09:35 AM
coolmision coolmision is offline
Regular
 
Join Date: Dec 2003
Posts: 71
Default

So, should I put the code into Private Subs? Could I put them into a module and then call them seperately so I dont have to place them in every form?
__________________
www.gamers2k4.com

Last edited by coolmision; 12-29-2004 at 09:35 AM. Reason: typo
Reply With Quote
  #4  
Old 12-29-2004, 09:36 AM
robertg's Avatar
robertg robertg is offline
Privileges Suspended
 
Join Date: Dec 2004
Location: Sterling Heights, MI
Posts: 520
Default

Regardless of whether they are on a form, or in a module, you would need to make them Public, rather than Private, if they were to be called from anywhere in your project, other than the form they are on. Probably a module would make more sense, yes.
Reply With Quote
  #5  
Old 12-29-2004, 09:37 AM
coolmision coolmision is offline
Regular
 
Join Date: Dec 2003
Posts: 71
Default

I'm kinda new to visual basic Thanks for the quick help, I'll tell you if it works as soon as possible. Thanks again!
__________________
www.gamers2k4.com
Reply With Quote
  #6  
Old 12-29-2004, 09:41 AM
eXeption's Avatar
eXeption eXeption is offline
Junior Contributor
 
Join Date: Aug 2004
Location: India
Posts: 270
Default

First up all, using Labels and GoTo is considered as a bad practice in coding. Try to avoid it by reorganising your code.
Anyway,
No direct methods, I think, Try setting a public flag in the form you want to jump, and when the form shows check the flag and jump to a suitable position.
__________________
"I think; therefore I am."
Reply With Quote
  #7  
Old 12-29-2004, 10:13 AM
crabby's Avatar
crabby crabby is offline
mostly gone

Retired Moderator
* Expert *
 
Join Date: Aug 2002
Location: London / UK
Posts: 2,721
Default

well or you load that second form modal try
Code:
Private Sub Command1_Click() Load Form2 Form2.Show vbModal MsgBox "second form is now closed" End Sub
__________________
there are always two sides of a story and 12 ways to sing a song or write some code. so whats wrong ?

Avatar by lebb
Reply With Quote
  #8  
Old 12-29-2004, 10:41 AM
HardCode's Avatar
HardCode HardCode is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Feb 2004
Location: New Jersey
Posts: 3,338
Default

After the .Show method, the rest of the code will still execute. Showing a form in a sub does not break execution of the rest of the code.

Edit: Oh, missed that vbModal
__________________
DON'T CLICK HERE

Useful forum tags: [VB][/VB], [CODE][/CODE], [HTML][/HTML]

Last edited by HardCode; 02-10-2005 at 11:19 AM.
Reply With Quote
  #9  
Old 12-29-2004, 10:48 AM
crabby's Avatar
crabby crabby is offline
mostly gone

Retired Moderator
* Expert *
 
Join Date: Aug 2002
Location: London / UK
Posts: 2,721
Default

Well it does on my machine. If I do the following I get the "did load the form" just after form2 is closed
Code:
Private Sub Command1_Click() Load Form2 Form2.Show vbModal Debug.Print "did load the form" End Sub
__________________
there are always two sides of a story and 12 ways to sing a song or write some code. so whats wrong ?

Avatar by lebb
Reply With Quote
  #10  
Old 12-29-2004, 11:58 PM
eXeption's Avatar
eXeption eXeption is offline
Junior Contributor
 
Join Date: Aug 2004
Location: India
Posts: 270
Default

morsnowski's code worked with me too!
__________________
"I think; therefore I am."
Reply With Quote
  #11  
Old 12-30-2004, 01:59 AM
Verphix Verphix is offline
Restricted
 
Join Date: Nov 2004
Posts: 444
Default

showing a form modally does stop the execution of code on the line it was called from. When the modal form is closed, only then the code continues.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->