How To Do Programming in VBScript
How To Do Programming in VBScript
Exit statement.
3
Do While/Until
Do[statements]
[statements]
Do
[ExitDo]
Do]
[Exit
[statements]
[statements]
Loop[{While
[{While||Until}
Until}condition]
condition]
Loop
6
iCount = iCount + 1
End If
Loop
Loop Until bCheck = False
Dim x
For x = 1 To 50
MyProc
Next
10
Dim j, itotal
For j = 2 To 10 Step 2
itotal = itotal + j
Next
Msg = "The total is " & itotal
11
12
13
Exit For
Provides a way to exit a For loop.
It can be used only in a For...Next or For Each...Next loop.
Exit Function
Immediately exits the Function procedure in which it appears.
Exit Property
Immediately exits the Property procedure in which it appears.
Exit Sub
Immediately exits the Sub procedure in which it appears.
14
Practice set
Input parameters names are From and To
Assume that both inputs are integers.
Display in reporter all the pairs between For and To
Use the For...Next loop.
Tip
Use the Step statement.
Concatenate to a temporary string.
Practice set
Input parameters names are Pswd.
Declare a constant MY_PASSWORD.
Declare a constant MAX_RETRY = 3.
If the password is correct display a micPass message.
If the password is typed wrong more then MAX_RETRY
times, display a micFail message.
Use the Do..Loop (While or Until).
Tip
Use the Exit Loop statement.
16
17