Flow Control Statements
-----------------------------
i) Conditional Statements
-------------------------------
a) If Statement
b) Select Case
Usage:
----------
Ex:
Dim myDate
myDate=#10/10/2010#
If myDate < Date Then myDate=Date
Msgbox myDate
myDate=#10/10/2012#
If myDate < Date Then myDate=Date
Msgbox myDate
--------------------------------------------------------------------
Dim a, b, c
a=100
b=20
If a>b Then
Msgbox "A is a Big Number"
End If
----------------------------------------------------
Dim a, b, c
a=100
b=200
If a>b Then
Msgbox "A is a Big Number"
Else
Msgbox "B is a Big Number"
End If
---------------------------------
ANSI Char codes
----------------------
'A-Z (65 to 90)
'a-z (97 to 122)
'0 - 9 (48 to 57)
---------------------------
Dim a, b, c
a=Cdbl (InputBox("Enter A Value"))
b=Cdbl (InputBox("Enter B Value"))
If a > b Then
Msgbox "A is a Big Number"
Else
Msgbox "B is a Big Number"
End If
-----------------------------------------------------
Dim a, b, c
a=InputBox("Enter A Value")
b=InputBox("Enter B Value")
If IsNumeric(a)=True And IsNumeric(b)=True Then
If Cdbl (a) > Cdbl (b) Then
Msgbox "A is a Big Number"
Else
Msgbox "B is a Big Number"
End If
Else
Msgbox "Invalid Data"
End If
--------------------------------------------------------------
Dim a, b, c
a=InputBox("Enter A Value")
b=InputBox("Enter B Value")
If IsNumeric(a) And IsNumeric(b) Then
If Cdbl (a) > Cdbl (b) Then
Msgbox "A is a Big Number"
Else
Msgbox "B is a Big Number"
End If
Else
Msgbox "Invalid Data"
End If
---------------------------------------------------------------------------
'Read value and Verify the range
'If the Value is in between 1 and 100 then display "Value is a Small Number
'If the Value is in between 101 and 1000 then display "Value is a Medium Number
'If the Value is in between 1001 and 10000 then display "Value is a Big Number
'If the Value is More than 10000 then display "Value is a High Number
'Otherwise display "value is Either zero or negative value"
'--------------------------------------------------------------------------------------------
Dim val
val=InputBox("Enter a Value")
If IsNumeric(val) Then
If val>= 1 And val<=100 Then
Msgbox "Val is a Small Number"
Elseif val> 100 And val<=1000 Then
Msgbox "Val is a Medium Number"
Elseif val> 1000 And val<=10000 Then
Msgbox "Val is a Big Number"
Elseif val> 10000 Then
Msgbox "Val is a High Number"
Else
Msgbox "Val is Either Zero or Negative"
End If
Else
Msgbox "Invalid Input"
End If
'--------------------
'50
'200
'2000
'12000
'0
'-100
'dgfhh
----------------------------------------------------------------------------------------------------------
'Read a Value and Verify if the value is Valid Mobile Number or Not
'Val should be a Numeric value
'Val should have 10 digits
'Val should start with either 9 or 8
'---------------------------------------------------------------------------------------------------
Dim val
val=InputBox("Enter a value")
If IsNumeric(val)=True Then
If Len(val)=10 Then
If Left(val, 1)=9 Or Left(val, 1)=8 Then
Msgbox "It is a valid Mobile Number"
Else
Msgbox "It is an Invalid Mobile Number"
End If
Else
Msgbox "It is not a 10 digit value"
End If
Else
Msgbox "It is not a Numeric value"
End If
-----------------
'handle . symbol
----------------------------------------------------------------------------------------
Dim num1, num2, Operation
num1=10
num2=20
Operation=LCase (InputBox("Enter an Operation"))
Select Case Operation
Case "add"
Msgbox "Addition of num1, num2 is: "&num1+num2
Case "sub"
Msgbox "Subtraction of num1, num2 is: "&num1-num2
Case "div"
Msgbox "Division of num1, num2 is: "&num1/num2
Case "mul"
Msgbox "Multiplication of num1, num2 is: "&num1*num2
Case Else
Msgbox "Invalid Operation"
End Select
-----------------------------------------------------------------------------------------------------------------
November 23rd 2011
------------------------------------------------------------------------------------------------------------------
For i= 1 to 10 step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
--------------------------------------------------------------------------------------------------------------------
For i= 11 to 20 step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
If Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").Exist(2) Then
Window("Flight Reservation").Dialog("Open Order").Dialog("Flight Reservations").WinButton("OK").Click
Window("Flight Reservation").Dialog("Open Order").WinButton("Cancel").Click
Reporter.ReportEvent micWarning,"Res","Up to "& i-1 &" Orders only available"
Exit For
End If
Next
-----------------------------------------------------------------------------------------------
i=1
While i <= 10
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
i=i+1
Wend
----------------------------------------------------------------------------------------------------------------------
i=1
Do While i <= 10
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
i=i+1
Loop
------------------------------------------------------------------------------------------------------------
i=14
Do
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
i=i+1
Loop While i <= 10
------------------------------------------------------------------------
i=1
Do Until i >10
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
i=i+1
Loop
----------------------------------------------------------------------------------------------------
i=1
Do
Window("Flight Reservation").Activate
Window("Flight Reservation").WinButton("Button").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Wait 2
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
i=i+1
Loop Until i >10
----------------------------------------------------------------------------------------------------------
Dim a, b, res(3)
a=10
b=20
res(0)="Addition of a, b is: "&a+b
res(1)="Subtraction of a, b is: "&a-b
res(2)="Division of a, b is: "&a/b
res(3)="Multiplication of a, b is: "&a*b
For Each Element in res
Msgbox Element
Next
=================================================
i=1
Do while(i<=5)
msgbox i
i=i+1
Loop
i=1
Do until(i=5)
msgbox i
i=i+1
Loop
this code related do while loop
i=1
Do
msgbox i
i=i+1
Loop While(i<=5)
this lkjlkasdjflkajskldjfklaskldfjasd
i=1
Do
msgbox i
i=i+1
Loop until(i=5)
----------------------------------------------------
a=2
b=1
If a>b Then
msgbox "ais big"
else
msgbox "bis big
End If
keyword=InputBox("enter data:")
Select Case keyword
Case "a","e","i"
msgbox "this isvowel"
Case else
msgbox "this is cosonent"
End Select
For i=1 to 5
msgbox i
Next
i=1
While I<=5
msgbox i
i=i+1
Wend
i=1
Do while I<=5
msgbox i
i=i+1
Loop
No comments
Post a Comment