• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

Code that allows for 3 actions on a YesNoCancel MsgBox without redisplaying the alert

I'm feeling kind of brain dead on this one.

    If MsgBox("Are you sure you want to process one incident only?", vbYesNoCancel) = vbCancel Then
    Exit Sub
    Else
    If MsgBox("Are you sure you want to process one incident only?", vbYesNoCancel) = vbNo Then
    GoTohere
    Else
    If MsgBox("Are you sure you want to process one incident only?", vbYesNoCancel) = vbYes Then
    GoTothere
    Else
    End If
    End If
    End If

Open in new window

This obviously re-displays the alert two more times unless you choose vbCancel.

So how do I write it?

Thanks,
John
0
John Carney
Asked:
John Carney
  • 2
1 Solution
 
Martin LissOlder than dirtCommented:
Dim intResponse as Integer

intResponse = MsgBox "Are you sure you want to process one incident only?", vbYesNoCancel

Select Case intResponse
    Case vbYes
        GoTohere
    Case vbNo
        GoTohere
    Case Else
        Exit Sub
End Select

Open in new window

0
 
John CarneyReliability Business Tools Analyst IIAuthor Commented:
Awesome, thanks MartinLiss. Just one little typo in line 3. I need to add the parentheses
intResponse = MsgBox ("Are you sure you want to process one incident only?", vbYesNoCancel)

Thanks,
John
0
 
Martin LissOlder than dirtCommented:
Yes, I typed that directly into the post and forgot the parentheses. In any case you're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2012
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now