Method: InputBox for VBS
- Updated2024-09-12
- 2 minute(s) read
Methods > Method: InputBox for VBS
Method: InputBox for VBS
Displays a prompt in a dialog box and returns the content of the textbox.
vInputBox = Object.InputBox(prompt, [title], [defaultValue], [xpos], [ypos], [helpfile], [context])
Object | VBS Object with this method. You do not need to specify this object. |
prompt | Variant Specifies the text that displays in the dialog box. The maximum length depends on the width of the characters and is approximately 1024 characters. |
[title] | Variant Specifies the text for the title bar of the dialog box. If you do not enter a title, the InputBox method displays the text VBScript in the title bar. |
[defaultValue] | Variant Specifies the value that the InputBox method displays in the input box by default. |
[xpos] | Variant Specifies the horizontal distance, in twips, between the left edge of the dialog box and the left edge of the screen. If you do not specify xpos, the InputBox method centers the dialog box horizontally. |
[ypos] | Variant Specifies the vertical distance, in twips, between the upper edge of the dialog box and the upper edge of the screen. If you do not specify ypos, the InputBox method centers the dialog box vertically. |
[helpfile] | Variant Specifies the path to a help file. The help file must be an HLP file. If you specify helpfile and context, the InputBox method automatically adds the Help button to the dialog box. |
[context] | Variant Specifies the ContextID of a help topic. |
vInputBox | Variant Returns the content of the textbox. If the user aborts the input process, the InputBox method returns an empty string: |
The following example shows an input box and displays the specified value:
Dim MyInput MyInput = InputBox("Enter your name","DIAdem","Nobody") Call MsgBox("You entered: " & MyInput)