VBScript InputBox Function
The InputBox function helps the user to get the values from the user.
After entering the values, if the user clicks the OK button or presses
ENTER on the keyboard, the InputBox function will return the text in
the text box. If the user clicks on the Cancel button, the function
will return an empty string ("").
Syntax
InputBox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
Parameter Description
• Prompt - A Required Parameter. A String that is displayed as a message
in the dialog box. The maximum length of prompt is approximately 1024
characters. If the message extends to more than a line, then we can
separate the lines using a carriage return character (Chr(13)) or
a linefeed character (Chr(10)) between each line.
• Title - An Optional Parameter. A String expression displayed in
the title bar of the dialog box. If the title is left blank,
the application name is placed in the title bar.
• Default - An Optional Parameter. A default text in the text
box that the user would like to be displayed.
• XPos - An Optional Parameter. The Position of X axis which
represents the prompt distance from left side of the screen
horizontally. If left blank, the input box is horizontally centered.
• YPos - An Optional Parameter. The Position of Y axis which
represents the prompt distance from left side of the screen
Vertically. If left blank, the input box is Vertically centered.
• helpfile - An Optional Parameter. A String expression that
identifies the Help file to use to provide context-sensitive
Help for the dialog box.
• context - An Optional Parameter. A Numeric expression that
identifies the Help context number assigned by the Help author
to the appropriate Help topic. If context is provided, helpfile
must also be provided.
Example
<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">
' Input Box with only Prompt
InputBox("Enter a number")
' Input Box with a Title
a=InputBox("Enter a Number","Enter Value")
msgbox a
' Input Box with a Prompt,Title and Default value
a=InputBox("Enter a Number","Enter Value",123)
msgbox a
' Input Box with a Prompt,Title,Default and XPos
a=InputBox("Enter your name","Enter Value",123,700)
msgbox a
' Input Box with a Prompt,Title and Default and YPos
a=InputBox("Enter your name","Enter Value",123,,500)
msgbox a
</script>
</body>
</html>
When the above script is executed, the input box is displayed
and displays the entered value by the user.
No comments:
Post a Comment