Micro Focus QTP (UFT) Forums
If Then statement inside For loop - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: If Then statement inside For loop (/Thread-If-Then-statement-inside-For-loop)



If Then statement inside For loop - Mala - 02-23-2011

Hi,
Below code is giving me some errors and am not able to figure it out why the errors are showing up??

Code:
Dim i
Set expectedResults = DataTable.GetSheet(dtGlobalSheet)
For i = 1 To 3
Browser("x").Page("y").WebEdit("a").Set DataTable("a", dtGlobalSheet)
Browser("x").Page("y").WebEdit("b").Set DataTable("b", dtGlobalSheet)
Set a = Browser("x").Page("y").WebEdit("a").GetROProperty("Value")
If a =  "[Select a] " Then
    Browser("x").Page("y").WebEdit("c").Set " "
    Else If  a =  "Value " Then
    Browser("x").Page("y").WebEdit("c").Set " "
    Else  If a =  "Value1 " Then
    Browser("x").Page("y").WebElement("d").Click
End If
Browser("x").Page("y").WebElement("e").Click
Browser("x").Page("y").WebElement("f").Check CheckPoint("f")
ExpectedResults.SetNextRow
Next

The above when saved gives me following errors
--Unexpected Next
--Expected End If

So changed the next and end if accordingly - but of no use.
Can anyone help me please???


RE: If Then statement inside For loop - manishbhalshankar - 02-23-2011

Hi Mala,

It is ElseIf. Remove the space between else and if from your code.


RE: If Then statement inside For loop - Mala - 02-23-2011

Thanks Manish


RE: If Then statement inside For loop - basanth27 - 02-23-2011

Did that work?