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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yes or no Query

Status
Not open for further replies.

AmatuerAtBest

Technical User
Jan 3, 2007
8
US
I am trying to pop up a box that asks the user a question, adn then he can either answer yes or no, with no other options. What would be the best way to go about this.

Thanks for any help.
 
Code:
If MsgBox("Take a Yes Or a No", vbYesNo, "Answer it") = vbYes Then
  MsgBox "It is a Yes, then", vbOkOnly, "You answered :"
Else
  MsgBox "It is a No, then", vbOkOnly, "You answered :"
End If
 
Same idea, but it may be easier to read:
Code:
Select Case MsgBox("Take a Yes Or a No", _
    vbYesNo Or vbQuestion Or _
    vbDefaultButton2, "Answer it")

    Case vbYes
         ...code for Yes
    Case vbNo
        ... code for NO
End Select
You may bypass vbDefaultButton2 part to have Yes a default button.

HTH

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top