Professional Documents
Culture Documents
B VBScript06
B VBScript06
B VBScript06
Session 6
Dani Vainstein 1
What we learn last session?
Dani Vainstein 2
Subjects for session 6
Dani Vainstein 3
An easy way to interact
Showing an output
MsgBox “Hello World!”
Getting an input:
Name = InputBox (“Who are you?”)
Dani Vainstein 4
The MsgBox function
Dani Vainstein 5
The InputBox function
Displays a prompt in a dialog box, waits for the user to input text or click a
button, and returns the contents of the text box.
Dani Vainstein 6
VBScript Constants
A number of useful constants you can use in your code are built
into VBScript.
Constants provide a convenient way to use specific values
without actually having to remember the value itself.
Using constants also makes your code more maintainable
should the value of any constant ever change.
Because these constants are already defined in VBScript, you
don't need to explicitly declare them in your code.
Simply use them in place of the values they
represent.
Dani Vainstein 7
Constants
MsgBox Constants
Defines constants used in the MsgBox function to describe
button visibility, labeling, behavior, and return values
Color Constants
Defines eight basic colors that can be used in scripting RGB,
CMYK.
Date and Time Constants
Defines date and time constants used by various date and time
functions.
Miscellaneous Constants
Defines constants that don't conveniently fit into any other
category.
Dani Vainstein 8
Constants
String Constants
Defines a variety of non-printable characters used in string
manipulation.
Tristate Constants
Defines constants used with functions that format.
VarType Constants
Defines The various variant subtypes.
Dani Vainstein 9
Excercise
Dani Vainstein 10
Lab 6.1
Use the InputBox for retrieve a password, title login to EX 6.1.
If the input is an empty string, exit the program.
Declare a constant MY_PASSWORD.
Declare a constant MAX_RETRY = 3.
If the password is correct display a MsgBox with a wellcome message +
information icon + EX 6.1 title.
Display a message each time password incorrect + question icon and a
question to retry or cancel the login process.
If the password is typed wrong more then MAX_RETRY times, display an
error message with an error icon, then exit the program.
Use the Do..Loop (While or Until).
Tip
Use the Exit Loop statement.
Check the value returned from MsgBox.
Dani Vainstein 11
Make sure to visit us
Tutorials
Articles
Projects
And much more
www.AdvancedQTP.com
12