NSB.MsgBox
NSB.MsgBox(function, prompt[, buttons[, title]])
Description
MsgBox opens a dialog box, and waits for the user to tap on a button. While it is displayed, no other actions may be taken by the user. Unlike MsgBox, this function does not halt the program: execution of the next statement will continue immediately. It will not wait for the user’s input. The advantages of this function are that title can be specified and that there are many more options for its appearance.
The function argument is the name of a subroutine or function in your program, which will be called when the control is dismissed. When the user clicks on button, function will be called with one of the values in the MsgBox Return Values table.
prompt, is a string expression that is displayed in the body of the dialog box. It can be plain text or HTML.
The optional parameter, buttons, is a numeric or string expression that specifies which buttons to draw and which icon to use. The default value for buttons is 0. Other values are obtained by adding the desired constants from the Button Constant table. The values vbCritical, vbQuestion, vbExclamation and VBInformation can be added to the button value to specify a preset icon.
buttons can also be a comma separated string of button names. In this case, the name of the button is returned. An example of a custom button string would be “btn1,btn2,btn3”. To have a preset icon, append its number to the string, as in "btn1,btn2,btn3;32" for three custom buttons and a question icon.
A custom icon can be specified by adding “;” and the name of the icon within the button string. The icon should be 33x33 pixels, but will be resized if different. For example, "btn1,btn2;images/customicon.gif" would result in two custom buttons and a custom image for icon.
The optional parameter, title, is a string expression that is displayed in the title bar of the dialog box. If title is not supplied, the title of the app is used.
To dismiss an NSB.MsgBox from your program instead of waiting for the user, call NSB.closeMsgBox().
Table 15: Button constants
Constant | Value | Description |
---|---|---|
vbOKOnly | 0 | OK Button only |
vbOKCancel | 1 | OK and Cancel buttons |
vbAbortRetryIgnore | 2 | Abort, Retry, and Ignore buttons |
vbYesNoCancel | 3 | Yes, No, and Cancel buttons |
vbYesNo | 4 | Yes and No buttons |
vbRetryCancel | 5 | Retry and Cancel buttons |
vbCritical | 16 | Critical Message icon |
vbQuestion | 32 | Warning Query icon |
vbExclamation | 48 | Warning Message icon |
vbInformation | 64 | Information Message icon |
Table 16: MsgBox return values
Constant | Value | Description |
---|---|---|
vbOK | 1 | Ok |
vbCancel | 2 | Cancel |
vbAbort | 3 | Abort |
vbRetry | 4 | Retry |
vbIgnore | 5 | Ignore |
vbYes | 6 | Yes |
vbNo | 7 | No |
Example
Title = "MsgBox Tour" 'Simple Message NSB.MsgBox("Hello World!") 'Simple Message with a custom title NSB.MsgBox("Brief Tour of MSGBOX!",0, Title) 'Yes/No Prompt. Call yesNoDone when finished NSB.MsgBox(yesNoDone,"Do you like this tour?", vbYesNo+vbQuestion, Title) 'Three Custom Buttons. Call custDone when finished. NSB.MsgBox(custDone,"How is NS Basic/App Studio?", "Fun,Great,Sweet", Title) 'Custom Button and Icon NSB.MsgBox("Who is the Happy Guy?", "Mario;mario.jpg", Title) Sub yesNoDone(result) If result=vbYes Then Text1.value="Yes" Else Text1.value="No" End Sub Sub custDone(result) Text2.value=result End Sub
Output
(depends on button. See nsbMsgBox sample)