0

Please help me to solve this problem beacause it is not working
the form2 dont show when i click the NO button please help me.
if you have any suggestion about my code please tell me!!
Form2_Unload()
box=msgbox("Do you want to exit",vbYESNO,"Exit?")
if box=yes then
unload me
else
form2.show
end if
end sub

Thanks in advance

5
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by scudzilla
0

In vb6 form_unload event there is a system defined event limited variable called 'cancel'. u need to assign this variable to 'no'. use this code snippet :-

private sub form_unload(cancel as integer)
dim box as integer

box=msgbox("Do you want to exit?",vbyesno,"Exit")
if box=vbyes then
unload me
set form2=nothing
end
elseif box=vbno then
cancel=vbno
form2.show
exit sub
endif
end sub

1

Here is the code:

Private Sub Form_Unload(Cancel As Integer)
box = MsgBox("Do you want to exit", vbYesNo, "Exit?")
If box = 7 Then
Cancel = True
End If
End Sub

greetings cards
dogs
:)

Votes + Comments
Whoa! I didn't know that. Thanks for the info. :)
0

Form2_unload() will not work unless you pass the control to it
A simple example will clear the doubt.

Create a command button say command2 in your form which you want to exit and caption it as EXIT.
In the general code add the control as below:

Private Sub Command2_click()
Unload me
End
End Sub

You have missed the End in your program code

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.