VBScript InputBox 函数
定义和用法
InputBox 函数可显示一个对话框,用户可在其中输入文本并/或点击一个按钮。如果用户点击点击确认按钮或按键盘上的回车键, 则 InputBox 函数返回文本框中的文本。如果用户点击取消按钮,函数返回一个空字符串("")。
注释:若同时规定helpfile 和 context 参数,则会向对话框添加一个帮助按钮。
提示:请参阅 MsgBox 函数。
语法
InputBox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
参数 | 描述 |
---|---|
prompt | 必需的。现实在对话框中的消息。prompt 的最大长度大约是 1024 个字符,这取决于所使用的字符的宽度。如果 prompt 中包含多个行,则可在各行之间用回车符 (Chr(13))、换行符 (Chr(10)) 或回车换行符的组合 (Chr(13) & Chr(10)) 以分隔各行。 |
title | Optional. String expression displayed in the dialog box title bar. If title is omitted, the name of the application will be displayed in the title bar. |
default | Optional. String expression displayed in the text box, which is used as the default response value when no other input is provided. If default is omitted, the text box is empty. |
xpos | Optional. Numeric expression used to specify the horizontal distance from the left edge of the dialog box to the left edge of the screen (in twips). If xpos is omitted, the dialog box is centered horizontally. |
ypos | Optional. Numeric expression used to specify the vertical distance from the top edge of the dialog box to the top edge of the screen (in twips). If ypos is omitted, the dialog box is displayed approximately one-third of the way from the bottom edge of the screen vertically. |
helpfile | Optional. String expression used to identify the help file that provides context-related help for the dialog box. If helpfile is provided, context must also be provided. |
context | Optional. Numeric expression used to identify the context number assigned to a help topic by the author of the help file. If context is provided, helpfile must also be provided. |
Example
dim fname fname=InputBox("Enter your name:") MsgBox("Your name is " & fname)