Odd closing problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a base form with a Cancel button (btnCancel) and a simple msgbox
routine. I would like to have a routine closing check to prevent loss of
data.

Dim i As Integer
i = MsgBox("Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.Question)
If i = MsgBoxResult.Yes Then
Me.DialogResult = DialogResult.Abort
Me.Dispose()
End If

I have another form that inherits from the base form. In both parent and
decendent the Cancel button property of the form is set to (None).

The problem is this. Even given the above, even given that I've traced the
code and can see that the Me.dispose call is NOT being made when I click No,
the form still closes. Any suggestions as to what I might be overlooking?
 
Hi

Call form.close when you press cancel button and form closing event you can
show the confirmation message:

Like:

Dim i As Integer
i = MsgBox("Exit?", MsgBoxStyle.YesNo + MsgBoxStyle.Question)
If i = MsgBoxResult.Yes Then
Me.DialogResult = DialogResult.Abort
Me.Dispose()
Else i = MSgBoxResult.No Then
e.Cancel = True
End If

Regards

Sooraj
Microsoft Community Star
 
Thanks! That worked perfectly.

(Although I'm still curious about what was causing the close in my original
example.)
 
Back
Top