Easy Tutorial
❮ Vbscript Ref Keywords Func Typename ❯

VBScript InputBox Function



The InputBox function displays a dialog box where 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 from 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

Parameter Description
prompt Required. The message displayed in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. If prompt contains multiple lines, you can separate the lines using a carriage return (Chr(13)), a linefeed (Chr(10)), or a combination of carriage return and linefeed (Chr(13) & Chr(10)).
title Optional. The title of the dialog box. The default is the application name.
default Optional. The default text in the text box.
xpos Optional. A numeric expression specifying the horizontal distance of the dialog box's left edge from the screen's left edge (in twips*). If xpos is omitted, the dialog box is centered horizontally.
ypos Optional. A numeric expression specifying the vertical distance of the dialog box's top edge from the screen's top edge (in twips*). If ypos is omitted, the dialog box is displayed approximately 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. Must be used with the context parameter.
context Optional. A numeric expression that identifies the context number assigned by the help file author to the appropriate help topic. Must be used with the helpfile parameter.

Examples

Example 1

Example 2

Prompt box with a title:

Example 3

Prompt box with default text in the input box:

Example 4

A prompt box displayed 700 twips* from the left edge of the screen.

Example 5

A prompt box displayed 500 twips* from the top edge of the screen.


❮ Vbscript Ref Keywords Func Typename ❯