 |

12-29-2004, 09:23 AM
|
|
Regular
|
|
Join Date: Dec 2003
Posts: 71
|
|
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
|

12-29-2004, 09:28 AM
|
 |
Privileges Suspended
|
|
Join Date: Dec 2004
Location: Sterling Heights, MI
Posts: 520
|
|
|
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.
|
|

12-29-2004, 09:35 AM
|
|
Regular
|
|
Join Date: Dec 2003
Posts: 71
|
|
|
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
|

12-29-2004, 09:36 AM
|
 |
Privileges Suspended
|
|
Join Date: Dec 2004
Location: Sterling Heights, MI
Posts: 520
|
|
|
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.
|
|

12-29-2004, 09:37 AM
|
|
Regular
|
|
Join Date: Dec 2003
Posts: 71
|
|
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
|

12-29-2004, 09:41 AM
|
 |
Junior Contributor
|
|
Join Date: Aug 2004
Location: India
Posts: 270
|
|
|
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."
|

12-29-2004, 10:13 AM
|
 |
mostly gone
Retired Moderator * Expert *
|
|
Join Date: Aug 2002
Location: London / UK
Posts: 2,721
|
|
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
|

12-29-2004, 10:41 AM
|
 |
Ultimate Contributor
Forum Leader * Expert *
|
|
Join Date: Feb 2004
Location: New Jersey
Posts: 3,338
|
|
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.
|

12-29-2004, 10:48 AM
|
 |
mostly gone
Retired Moderator * Expert *
|
|
Join Date: Aug 2002
Location: London / UK
Posts: 2,721
|
|
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
|

12-29-2004, 11:58 PM
|
 |
Junior Contributor
|
|
Join Date: Aug 2004
Location: India
Posts: 270
|
|
|
morsnowski's code worked with me too!
|
__________________
"I think; therefore I am."
|

12-30-2004, 01:59 AM
|
|
Restricted
|
|
Join Date: Nov 2004
Posts: 444
|
|
|
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.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|