Msgbox

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

Guest

How do i use VKokCancel in a message box
I can't get it to work?

regards alvin
 
One way:


Dim nResult As Long
nResult = MsgBox(Prompt:="Erase your hard drive?", _
Buttons:=vbOKCancel)
If nResult = vbCancel Then
MsgBox "You cancelled..."
Else
MsgBox "Just kidding!"
End If
 
Set a variable to the MsgBox results

ans = MsgBox(...)

and test that for vbOK or vbCancel

If ans = vbOK then
...
ElseIf ans = vbCancel Then
...

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Sub ABCD()
Dim ans As Long
ans = MsgBox("Ok or Cancel?", vbOKCancel)
If ans = vbOK Then
MsgBox "You clicked OK"
ElseIf ans = vbCancel Then
MsgBox "You clicked cancel"
End If
End Sub
 
Thank you all

So simpel.............................................

regards alvin


"Tom Ogilvy" skrev:
 
Funny AND helpful... Cheers

JE McGimpsey said:
One way:


Dim nResult As Long
nResult = MsgBox(Prompt:="Erase your hard drive?", _
Buttons:=vbOKCancel)
If nResult = vbCancel Then
MsgBox "You cancelled..."
Else
MsgBox "Just kidding!"
End If
 

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

Similar Threads

count where item =x 8
using variable in subject when send mail 2
filesystemobject 2
Use Bcc 2
ComboboxStart item 2
Vba Password 1
Filesystem again 1
Project is unviawable 4

Back
Top