6. VbScript | Input Box

In this tutorial, we will be talking about the Input Box in vbscript. The Input Box is a valuable function because it allows the user to give more feedback back to the VbScript than the Message Box. Specifically, you can enter characters for the Input Box, but you can only click on a button for Message Box. To re-iterate, the function of the Input Box is to give text input back to the VbScript, where as the function of the Message Box is to show a message while allowing limited input through buttons.

Input is important because it gives us more control over what the VbScript can do. To understand the value of input, imagine if you only had 4 keys versus a full set of keys on your keyboard. What we are able to do with computers is highly dependent on the input we are able to give it.

Input Box Format:

An example of a Input Box script:



To put in a title for an input box:



To keep a preset value in the empty Input field:



You can also control what position the Input Box appears on the screen.


Demonstration (I start talking about the positioning at the 1 minute mark):

Now if we want to set the Input Box to give us feedback, we have to store what is typed into the input field as a variable:

Note that the () tells the vbscript what is included for the inputbox, which is equal to the name variable.



Clicking Cancel results in an empty message box, because there was no input. But Clicking OK stores the text in the name variable. And the message box spits back out what the name variable is:


What's Your Opinion?