SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 707 | Next

David A. Karp

"Windows Vista Annoyances: Tips, Secrets, and Hacks"

")
will display a prompt on the screen when the script is run, asking for some
text to be typed. When you enter some text and click OK, the script places
the text you??™ve typed into the variable MyName and continues on to the next
command.
Now, collecting and rearranging information does no good without the ability
to spit out a result. The versatile MsgBox function allows you to display a
simple message, as follows:
MsgBox "Hello, Hello Again."
Combining the principles covered so far, consider the following code:
MyAge = InputBox("Please type your age.")
NewAge = MyAge + 5
MsgBox "In 5 years, you will be " & NewAge & "."
The first line does two things: it first asks the user to type something, and
then assigns the typed text to the variable MyAge. The second line creates a
new variable, NewAge, assigns the user??™s input to it, and adds five. Note the
lack of any error checking in this example: if one enters something other
than a number, this code will cause a WSH error, and the script will end
early. The third line then uses the & operator to concatenate (glue together) a
text string to the NewAge variable and displays the result in a message box.
Build a VBScript Script | 517
Scripting and
Automation
Notice that plain text is always enclosed in quotation marks, but variable
names are not. If you were to enclose the NewAge variable in quotation
marks, the script would simply print out the text NewAge instead of whatever
value is stored in the variable.


Pages:
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6