msgbox with cancel

  • Thread starter Thread starter Paradigm
  • Start date Start date
P

Paradigm

I want to use a msgbox for the user to select from 3 option yes, no and
cancel. I know how to format the msgbox to display the 3 buttons and I know
how to trap the yes and no
eg
if msgbox("select option",35,"myinput")=vbno then
dosomething
else
dosomethingdifferent
end if

but how do I detect if the user selectes the cancel button.

Alec
 
Hi Alec

Use a Select Case statement. Also, the "35" is kind of arcane! I suggest
you use the msgbox style constants:

Select Case MsgBox("select option", vbQuestion + vbYesNoCancel,"myinput")
Case vbYes
dosomething
Case vbNo
dosomethingdifferent
Case vbCancel
dosomethingdifferentagain
End Select
 
Paradigm said:
I want to use a msgbox for the user to select from 3 option yes, no
and cancel. I know how to format the msgbox to display the 3 buttons
and I know how to trap the yes and no
eg
if msgbox("select option",35,"myinput")=vbno then
dosomething
else
dosomethingdifferent
end if

but how do I detect if the user selectes the cancel button.

Alec

Select Case MsgBox("select option", vbYesNoCancel, "myinput")
Case vbNo
DoOption_No
Case vbYes
DoOption_Yes
Case vbCancel ' or Case Else
DoOption_Cancel
End Select
 

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

Back
Top