Close Button

G

Guest

I have a login form and after name and password that forms closes and my
database form opens up. I need to code so that when a user clicks the close
button (the X on top right) it displays a dialog that gives them the option
to cancel or exit. If they exit it brings back the login form. I have it
code but when I hit the X and if they chose to cancel it closes my form. So
basically how do I display a dialog for X and if cancel is hit then nothing
happens?
 
H

Herfried K. Wagner [MVP]

Dave said:
So basically how do I display a dialog for X and if cancel is hit
then nothing happens?

\\\
Private Sub Form1_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs _
) Handles MyBase.Closing
If _
MsgBox( _
"Really close?", _
MsgBoxStyle.YesNo Or MsgBoxStyle.Question _
) = MsgBoxResult.No _
Then
e.Cancel = True
End If
End Sub
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top