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

using MsgBox InputBox

Status
Not open for further replies.

WintersMystic

Programmer
Aug 8, 2001
39
US
ok, regardless of the word programmer, i didnt know what to choose, i am not one. only a few days into VBScript.

when using InputBox and MsgBox how do you decide what the ok and cancel buttons do?

ive tried.

Code:
Sub cmdButton_OnClick
dim stuff
stuff=MsgBox "Hi", vbOKCancel, "Thanx"
If stuff then
MsgBox "Great", vbOK, "Thanx"
End If
End Sub
[color]
of course it didnt work. so how does one do this?
 
buttons

Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. See Settings section for values. If omitted, the default value for buttons is 0.
The buttons argument settings are:

Constant Value Description
vbOKOnly 0 Display OK button only.
vbOKCancel 1 Display OK and Cancel buttons.
vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.
vbYesNoCancel 3 Display Yes, No, and Cancel buttons.
vbYesNo 4 Display Yes and No buttons.
vbRetryCancel 5 Display Retry and Cancel buttons.
vbCritical 16 Display Critical Message icon.
vbQuestion 32 Display Warning Query icon.
vbExclamation 48 Display Warning Message icon.
vbInformation 64 Display Information Message icon.
vbDefaultButton1 0 First button is default.
vbDefaultButton2 256 Second button is default.
vbDefaultButton3 512 Third button is default.
vbDefaultButton4 768 Fourth button is default.
vbApplicationModal 0 Application modal; the user must respond to the message box before continuing work in the current application.
vbSystemModal 4096 System modal; all applications are suspended until the user responds to the message box.

Return Values
The MsgBox function has the following return values:

Constant Value Button
vbOK 1 OK
vbCancel 2 Cancel
vbAbort 3 Abort
vbRetry 4 Retry
vbIgnore 5 Ignore
vbYes 6 Yes
vbNo 7 No


 
or if you are wanting to see which button was pressed, do the following:

if stuff = vbok then
...Some Code...
Else 'Cancel Button Was Pressed
...Some Code...
End If

Hope this also helps. I found that it is easier to use the constants rather than try to add a bunch of numbers. If you need a list of them, I can post it for you. Tazzmann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top