InputBox, InputBox$ (functions)


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


Displays a dialog box with a text box into which the user can type.


The content of the text box is returned as a String (in the case of InputBox$) or as a String variant (in the case of InputBox). A zero-length string is returned if the user selects Cancel.

The InputBox/InputBox$ functions take the following named parameters:






Text to be displayed above the text box. The prompt parameter can contain multiple lines, each separated with an end-of-line (a carriage return, line feed, or carriage-return/line-feed pair). A runtime error is generated if prompt is Null.



Caption of the dialog box. If this parameter is omitted, then no title appears as the dialog box's caption. A runtime error is generated if title is Null.



Default response. This string is initially displayed in the text box. A runtime error is generated if default is Null.


xpos, ypos

Integer coordinates, given in twips (twentieths of a point), specifying the upper left corner of the dialog box relative to the upper left corner of the screen. If the position is omitted, then the dialog box is positioned on or near the application executing the script.



Name of the file containing context-sensitive help for this dialog. If this parameter is specified, then context must also be specified.



Number specifying the ID of the topic within helpfile for this dialog's help. If this parameter is specified, then helpfile must also be specified.


You can type a maximum of 255 characters into InputBox.

If both the helpfile and context parameters are specified, then a Help button is added in addition to the OK and Cancel buttons. Context-sensitive help can be invoked by selecting this button or using the help key (F1 on most platforms). Invoking help does not remove the dialog.

When Cancel is selected, an empty string is returned. An empty string is also returned when the user selects the OK button with no text in the input box. Thus, it is not possible to determine the difference between these two situations. If you need to determine the difference, you should create a user-defined dialog or use the AskBox function.


Sub Main()

  s$ = InputBox$("File to copy:","Copy","sample.txt")

End Sub

See Also

MsgBox (statement), AskBox, AskBox$ (functions), AskPassword, AskPassword$ (functions), OpenFileName$ (function), SaveFileName$ (function), SelectBox (function), AnswerBox (function)

More information