Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox - vbOKCancel

Status
Not open for further replies.

GerardMcL

Technical User
Aug 5, 2004
212
0
0
IE
Hi,
I have a delete procedure and before the command is executed a Msgbox asks the user are they sure
It is a vbOkCancel box
How do I write code so that if the user selects
OK - Proceed with Code
Cancel - Stops action

By the way this box is included within an If loop If .. Else statement
 
try something like this


Code:
    If MsgBox("Are you sure?", vbOKCancel) = vbOK Then
        'Do delete bit here
    Else
        ' do cancel stuff here.
    End If

regards

Matt

If you can keep your head while those around you are losing theirs, you obviously haven't grasped the seriousness of the situation
 

Or along the same lines this
Code:
Select Case MsgBox("Please chose", vbYesNoCancel Or vbExclamation Or vbDefaultButton1, "")

	Case vbYes
           'Do something
	Case vbNo
            'Do something
	Case vbCancel
              'Do something
End Select

Hope this helps!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top