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 709 | Next

David A. Karp

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


When the user responds to the message box, the Response variable will be
set to:
1 if the user clicked OK
2 for Cancel
3 for Abort
4 for Retry
5 for Ignore
6 for Yes
7 for No
The next step is to write code that can perform different functions based on
this recorded response. See the next topic, ???Creating Interactive Scripts with
Conditional Statements,??? for details on using the results from a MsgBox statement
to determine what happens next in a script.
Creating Interactive Scripts with Conditional Statements
Conditional statements allow you to redirect the flow depending on a condition
you determine, such as the value of a variable. Take, for example, the
following script:
Response = MsgBox("Do you want to continue?", 32 + 4, "Next Step")
If Response = 7 Then WScript.Quit
MsgBox "You asked for it..."
The first statement uses the MsgBox function, described in the previous topic,
to ask a question. The value of 32 + 4 specifies Yes and No buttons, as well
as the question mark icon. If the user chooses Yes, the value of the Response
variable is set to 6; if No is chosen, Response is set to 7.
The next statement uses the vital If...Then structure to test the value of the
Response variable. If it??™s equal to 7 (meaning the user clicked No), then the
script exits immediately (using the WScript.Quit statement). Otherwise,
script execution continues to the next command.
Here??™s another example using a slightly more complex version of the If
statement:
Build a VBScript Script | 519
Scripting and
Automation
MyShoeSize = InputBox("Please type your shoe size.


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