MsgBox Function
Description
Displays a dialog box containing a message, buttons, and optional icon to the user. The action taken by the user is returned by the function as an integer value.
Syntax
MsgBox(prompt, buttons, title, helpfile, context)
Parameter Description
prompt The text of the message to display in the message box dialog.
buttons The sum of the Button, Icon, Default Button, and Modality constant values.
title The title displayed in the Title-bar of the message box dialog.
helpfile An expression specifying the name of the help file to provide help functionality for the dialog.
context An expression specifying a context ID within helpfile.
Notes
prompt can contain approximately 1,000 characters, including carriage return characters such as the built-in vbCrLf or vbNewLine constants.
In order to divide prompt onto multiple lines, you can use any of the vbCr, vbLf, vbCrLf, or vbNewLine constants. For example:
sMsg = "This is line 1" & vbNewLine & "This is line 2"
If the helpfile parameter is provided, the context parameter must also be provided, and vice versa.
When both helpfile and context are passed to the MsgBox function, a Help button is automatically placed on the MsgBox dialog, allowing the user to
click and obtain context-sensitive help.
If you omit the buttons argument, the default value is 0; VBScript opens an application modal dialog containing only an OK button.
The following intrinsic constants can be added together to form a complete buttons argument
Showing posts with label INTERACTION FUNCTIONS. Show all posts
Showing posts with label INTERACTION FUNCTIONS. Show all posts
Tuesday, November 22, 2011
InputBox Function VB Script
InputBox Function
Description
The InputBox function displays a dialog box containing a label, which prompts the user about the data you expect them to input, a text box for entering the data, an OK button, a Cancel button, and optionally, a Help button. When the user clicks OK, the function returns the contents of the text box
Syntax
Description
The InputBox function displays a dialog box containing a label, which prompts the user about the data you expect them to input, a text box for entering the data, an OK button, a Cancel button, and optionally, a Help button. When the user clicks OK, the function returns the contents of the text box
Syntax
InputBox(prompt,title,default,xpos, ypos, helpfile, context)
Arguments
Constant Description
prompt The message in the dialog box.
title The title-bar of the dialog box.
default String to be displayed in the text box on loading.
xpos The distance from the left side of the screen to the left side of the dialog.
ypos The distance from the top of the screen to the top of the dialog box.
helpfile The Help file to use if the user clicks the Help button on the dialog box.
context The context number to use within the Help file specified in helpfile.
Constant Description
prompt The message in the dialog box.
title The title-bar of the dialog box.
default String to be displayed in the text box on loading.
xpos The distance from the left side of the screen to the left side of the dialog.
ypos The distance from the top of the screen to the top of the dialog box.
helpfile The Help file to use if the user clicks the Help button on the dialog box.
context The context number to use within the Help file specified in helpfile.
Notes
1. InputBox returns a string containing the contents of the text box from the
Input-box dialog.
2. If the user clicks Cancel, a zero-length string (" ") is returned.
3. prompt can contain approximately 1,000 characters, including nonprinting
characters like the intrinsic vbCrLf constant.
4. If you don't use the default parameter to specify a default entry for the text
box, the text box is shown empty; a zero-length string is returned if the
user doesn't enter anything in the text box prior to clicking OK.
5. xpos and ypos are specified in twips. A twip is a device-independent unit of
measurement that equals 1/20 of a point or 1/1440 of an inch.
6. If the xpos parameter is omitted, the dialog box is centered horizontally.
7. If the ypos parameter is omitted, the top of the dialog box is positioned
approximately one-third of the way down the screen.
8. If the helpfile parameter is provided, the context parameter must also be
provided, and vice versa.
9. In VBScript, when both helpfile and context are passed to the InputBox
function, a Help button is automatically placed on the InputBox dialog,
allowing the user to click and obtain context-sensitive help.
sString = InputBox("Enter it now", , "Something", , , "help.hlp", 321321)
Example
The following example uses the InputBox function to display an input box and
assign the string to the variable Input:
Option Explicit
Dim sPrompt, sTitle, sHelpFile, sRes
Dim vDef
Dim nYPos, nXPos, nContext
sPrompt = "Where do you live?" : sTitle = "Personal Data"
vDef = "Israel"
nXPos = 100 : nYPos = 100 : nContext = 1001
sHelpFile = "C:\WINDOWS\system32\winhelp.hlp"
sRes = InputBox(sPrompt, sTitle, vDef, nXPos, nYPos, sHelpFile, nContext)
Subscribe to:
Posts (Atom)