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

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

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
:)

commented: Whoa! I didn't know that. Thanks for the info. :) +1

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

End is not advisable to use. Unload me is actually fine by itself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.