PC Tools - Essential tools for your PC
Search
 
 
Features
 
Newsletter
 

Interacting with Users

Let’s try a script with a few more features, again using Notepad enter the following text, and save it as "script2.vbs":
Dim strName 'Define the variable

strName = InputBox("Enter your name:") 'Get the users name

WScript.echo "Hello " & strName 'Show the user the name entered

When you run this script, the first thing you will see is an input box requesting your name (this is generated with the InputBox() function), enter your name and click OK.

InputBox Example

The next screen will show you the name entered on the first screen using the WScript.Echo method.

Popup Example

To see how this script works let’s go through it line-by-line; on the first line we define the variable "strName", a variable is used to store information, in this case a persons name. On the second line we used to InputBox() function to request the user for some information, we then take the response and place it in the "strName" variable. On the final line, we display the information back to the user, for this we used the WScript.Echo method that prints the supplied text on the users screen.

< Hello World!

1 + 1 = ? >

 
  Copyright © 1998-2008 PC Tools. All rights Reserved. Privacy Policy | Legal Notice 


Are you looking for Mac security software?
PC Tools now offers iAntiVirus, a free antivirus product for Mac OS X. Please click below to learn more.

Tell me more No, thanks

Remember my answer