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

how to send a response "YES" for a message BOX

Status
Not open for further replies.

jmgs98

MIS
May 10, 2004
9
MX
how to send a response "YES" for a message BOX using VB commands and do not have to manually input the yes while running the program?

Thanks,
 
I'm not sure I understand your question, but here is an answer:

Clicking on the Yes button in a Yes/No messagebox will return the value of vbYes.

So, you could do the following:

Code:
Dim response as Integer
response = MsgBox ("Are you sure?", vbYesNo)
if response = vbYes Then
    'do stuff if user says yes
Else
    'do stuff if user says no
End If

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
or,
Code:
If MsgBox ("Are you sure?", vbYesNo) = vbYes Then
    'do stuff if user says yes
Else
    'do stuff if user says no
End If


zemp
 
Touché.

However, this may get slightly messier with, say, a vbYesNoCancel Messagebox, where you may want to do something for different button events.

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
Yes, with vbYesNoCancel (three choices) I like to use a response integer and a Select Case structure.

zemp
 
It has a better explanation of his real question.

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top