Friday, April 9, 2010

VB Scripting Basics - Input Box Function

Previous12345678910Next

Input box function in VB Scripting is used to get information from the user and then that value is stored in a variable.


Type in the statement below in your note pad and save as sample2.


UserInput = Inputbox(“Please Enter your Name”)


When you execute the file by double clicking it is displayed like this.


“UserInput” in the above statement is a variable and whatever the user enters in the text box is stored in the variable called “UserInput”. If we want to view the data entered on the screen then we need to call this variable in the Msgbox function and the variable value is displayed for the user. In order to do this modify your code like this

UserInput = Inputbox(“Please Enter your Name”)
Msgbox  UserInput


When you execute the file again with this changes what happens. First you are prompted to enter a value and clicking OK button will display the message box with the value entered.

To put in as a definition Input box is an inbuilt VB Scrip function used for getting an input from the user during runtime. Input box provides a text box and allows the user to type in some data. When the user clicks the OK button this data is assigned to a variable. The default input type for an input box is a string.

Previous12345678910Next

2 comments:

Naveen Kumar S said...

Hi Kiran, I am not getting the text entered my us in msbbox , It shows UserInput itself.

Naveen Kumar S said...

Kiran I found out there should not be _ " _ (Quotation mark) around Username.
Please Correct.

Post a Comment