W3Schools.com

VBScript InputBox Function


VBScript Reference Complete VBScript Reference

The InputBox function displays a dialog box, where the user can write some input and/or click on a button. 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 ("").

Note: A Help button is added to the dialog box when both the helpfile and the context parameter are specified.

Tip: Also look at the MsgBox function.

Syntax

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

Parameter Description
prompt Required. The message to show in the dialog box. Maximum length is 1024 characters. You can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or carriage return–linefeed character combination (Chr(13) & Chr(10)) between each line
title Optional. The title of the dialog box. Default is the application name
default Optional. A default text in the text box
xpos Optional. The prompt box' distance from the left edge of the screen. Measurement unit: twips*. If omitted, the dialog box is horizontally centered.
ypos Optional. The prompt box' distance from the top edge of the screen. Measurement unit: twips*. If omitted, the dialog box is vertically positioned one-third of the way down the screen
helpfile Optional. The name of a Help file to use. Must be used with the context parameter
context Optional. The Help context number to the Help topic. Must be used with the helpfile parameter

* A twip is a measurement unit that is visually the same on all display systems.
1 twip is 1/1440 of an inch.

Examples

Example 1

<script type="text/vbscript">

Function myFunction()
fname=InputBox("Enter your name")
End Function

</script>

Try it yourself »

Example 2

A prompt box with a title:

<script type="text/vbscript">

Function myFunction()
fname=InputBox("Enter your name","Userinput")
End Function

</script>

Try it yourself »

Example 3

A prompt box with a deafult text in the inputbox:

<script type="text/vbscript">

Function myFunction()
fname=InputBox("Enter your name",,"Donald Duck")
End Function

</script>

Try it yourself »

Example 4

A prompt box wich is positioned 700 twips* from the left edge of your screen.

<script type="text/vbscript">

Function myFunction()
fname=InputBox("Enter your name",,,700)
End Function

</script>

Try it yourself »

Example 5

A prompt box wich is positioned 500 twips* from the top edge of your screen.

<script type="text/vbscript">

Function myFunction()
fname=InputBox("Enter your name",,,,500)
End Function

</script>

Try it yourself »

VBScript Reference Complete VBScript Reference
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE