VBScript InputBox Function
Complete VBScript Reference Manual
The InputBox function displays a dialog box in which the user can enter text and/or click a button. If the user clicks the OK button or presses the ENTER key on the keyboard, the InputBox function returns the text in the text box. If the user clicks the Cancel button, the function returns an empty string ("").
**Note:** If both the helpfile and context parameters are specified, a Help button is added to the dialog box.
**Tip:** See the MsgBox function.
Syntax
InputBox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
| Parameters | Description |
|---|---|
| prompt | Required. The message displayed in the dialog box. The maximum length of prompt is about 1024 characters, depending on the width of the characters used. If prompt contains multiple lines, you can separate the lines with a carriage return (Chr(13)), a line feed (Chr(10)), or a combination of both (Chr(13) & Chr(10)). |
| title | Optional. The title of the dialog box. The default is the name of the application. |
| default | Optional. Default text in the text box. |
| xpos | Optional. A numeric expression specifying the horizontal distance between the left edge of the dialog box and the left edge of the screen (in twips*). If xpos is omitted, the dialog box is centered horizontally. |
| ypos | Optional. A numeric expression specifying the vertical distance between the top edge of the dialog box and the top edge of the screen (in twips*). If ypos is omitted, the dialog box appears about one-third of the way down the screen. |
| helpfile | Optional. A string expression identifying the help file that provides context-sensitive help for the dialog box. It must be used with the context parameter. |
| context | Optional. A numeric expression identifying the context number assigned to a help topic by the author of the help file. It must be used with the helpfile parameter. |
- A twip is a unit of measurement that visually corresponds to the system display.
1 twip is 1/1440 of an inch.
Example
Example 1
Try it »
Example 2
A prompt box with a title:
Try it »
Example 3
A prompt box with default input text:
Try it »
Example 4
A prompt box displayed 700 twips* from the left edge of the screen.
Try it »
Example 5
A prompt box displayed 500 twips* from the top edge of the screen.
Try it »
Complete VBScript Reference Manual