Message Box

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

Guest

I have a message box come up on a command button. It has the options: ok and
cancel after displaying the message. How do you set it up so that if cancel
is selected it exits the sub? Thanks in advance.

Neil Cash
 
Try:
Dim intResponse as Integer

If intResponse =Msgbox(Prompt:="...", buttons:=vbOkCancel)
=vbCancel Then
Exit Sub
End If

Geof.
 
You need to use the MsgBox Function instead of the MsgBox dialog.

If MsgBox("SomeMsgBoxTEXT", vbYesNoCancel, "SomeCaptionTEXT") = vbCancel Then
Exit Sub
End If
 
Thanks a bunch!

MikeB said:
You need to use the MsgBox Function instead of the MsgBox dialog.

If MsgBox("SomeMsgBoxTEXT", vbYesNoCancel, "SomeCaptionTEXT") = vbCancel Then
Exit Sub
End If
 
Back
Top