vbscript InputBox


Syntax

  • InputBox(prompt[, title][, default][, xpos][, ypos][, helpfile, context])

Parameters

ArgumentDetail
promptText to display above the input field (usually an instruction as to what is required form the user).
titleCaption displayed in the titlebar of the input box.
defaultA placeholder for the text field, used as the return value if the user doesn't overwrite.
xposHorizontal distance in twips to display input box from the left edge of the screen.
yposVertical distance in twips to display input box from the top edge of the screen.
helpfileA string to determine the help file to be used in order to provide contextual help with the input box.
contextIf the helpfile argument is supplied, a context number must also be supplied to identify the appropriate help topic in the help file.

Remarks

1All arguments except prompt are optional.
2helpfile and context are coupled - if one is supplied, the other must also be supplied.

Use InputBox to assign user input to a string

' Omitting the 4th and 5th argument ("xpos" and "ypos") will result in the prompt
' being display center of the parent screen

exampleString = InputBox("What is your name?", "Name Check", "Jon Skeet", 2500, 2000)

WScript.Echo "Your name is " & exampleString