|
-
Jun 5th, 2002, 03:34 AM
#1
END statement
I use END statement when the user press the Cancel button on my vbYesNoCancel MsgBox.
But when I use the End statement it clear all my variables.
But I wanna preserve the value of my variables. And I use the Stop statement instead. But it doesen't work? Why?
-
Jun 5th, 2002, 03:37 AM
#2
^:^...ANGEL...^:^
Try this...
Don't put any code in CANCEL event...
I hope that you don't want to close you app with END...
Dim intYesNo as Integer
intYesNo = msgbox ("TEST",vbYesNoCancel)
if intYesNo = vbYes then
' Do something
endif
if intYesNo = vbNo then
' Do something
endif
==============
-
Jun 5th, 2002, 03:46 AM
#3
If I don't put any code in CANCEL event my code continue to next sub...
-
Jun 5th, 2002, 05:59 AM
#4
Addicted Member
if intYesNo = vbCancel then
Exit sub
end if
-
Jun 5th, 2002, 06:05 AM
#5
^:^...ANGEL...^:^
what exactly you want to do...
Do want to CLOSE the app or just get out of that sub...???
if you just want to get out of sub then use GARY's code...
or post here what exactly you are looking for...
Cheers..........
-
Jun 5th, 2002, 06:55 AM
#6
I don't want to CLOSE the app...only STOP the current subs and functions and when I use the End statement it clear all my variables.
But I wanna preserve the value of my variables...
-
Jun 5th, 2002, 07:00 AM
#7
^:^...ANGEL...^:^
OK then...
Dim I As Integer
I = MsgBox("TEST", vbYesNoCancel)
If I = vbYes Then
MsgBox "YES"
End If
If I = vbNo Then
MsgBox "NO"
End If
If I = vbCancel Then
End
End If
-
Jun 5th, 2002, 07:03 AM
#8
Originally posted by Gary007
if intYesNo = vbCancel then
Exit sub
end if
Use this. If you want to close your app when the user clicks Cancel use this:
VB Code:
if intYesNo = vbCancel then
Unload me
end if
-
Jun 5th, 2002, 07:06 AM
#9
Do you mean you want to close you application, but want to preserve the value of your variables?
If you close an application, the memory will be cleared, so if you want to save them, you will have to write them to disk somehow, and read them in when you start the application again.
There are numerous ways to save something to disk, like a database, the registry, a text file, an XML file etc.
-
Jun 5th, 2002, 09:18 AM
#10
I don't want to CLOSE the app...only STOP the current subs and functions and when I use the End statement it clear all my variables.
But I wanna preserve the value of my variables...
-
Jun 5th, 2002, 09:24 AM
#11
You can only stop the current sub.
If you want to jump out of the calling sub then you have to use parameters.
If the value given is from jump out of sub (Exit Sub)
then exit the calling sub too.
Hope this clears your mind.
If not post some code to show the place you are trying to exit
-
Jun 5th, 2002, 09:24 AM
#12
PowerPoster
Well
Two things :
First : Don't use END.
Use :
VB Code:
Dim frm As Form
For Each frm In Forms
Unload Me
Set frm = Nothing
Next
Second : How do you want to store the variables? As mentioned, there are many different options...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Jun 5th, 2002, 09:38 AM
#13
Fanatic Member
VB Code:
If MsgBox("This is the message" vbYesNoCancel, "Title") = vbCancel Then
Exit Sub
End If
If the variables you want to preserve are declared in this sub they won't be preserved, you will have to declare them in the General Declarations.
"I have not failed. I've just found 10,000 ways that won't work."
'Thomas Edison'
"If we knew what it was we were doing it wouldn't be called research, would it?"
'Albert Einstein'
VB6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|