borderAndreaVB free resources for Visual Basic developersborder
AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2017 Andrea Tincani
:: Protect the form unloading in accidently

Author  

Arivoli

Language  

VB5, VB6

Operating Systems  

Windows 95, 98, NT, 2k, Me and XP
Usage
When you want ot protect the form unload in accidently you can use this following code.
In this code, the action is When a form is prepared to 
unload The unload event was automatically raised.
on that event there is an parameter named "Cancel" which in the data type integer. 
When the unload event is raised the "cancel" has the value as 0.
If the value of "Cancel" is 0 the form is automatically unloaded.
If we change the value to 1 the form was never end. So I wrote the code as follows...
private sub form1_unload(Cancel as Integer)
   a = MsgBox "Do u want to close?",vbYesNo,"Alert Message"
   If a = vbYes Then
       Cancel = 0
   Else
       Cancel = 1
   End If
End Sub
:: Navigation

Home

Beginners Corner

Previous Tip

Next Tip

:: Search this site
Google
borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2017 Andrea Tincaniborder