Micro Focus QTP (UFT) Forums
While Wend condition - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: While Wend condition (/Thread-While-Wend-condition)



While Wend condition - raaj123 - 06-11-2012

hi sir,

Please help me while condition is not working it is directly moving to next.

pls see the below code.


Code:
empid=ASF467  
For i=2 to rowcnt
        ecl=wrksht.cells(i,2)
        eempid=wrksht.cells(i,1)
        msgbox cstr(eempid)----here eempid is ASF467  
        msgbox ecl
        while cstr(empid)=cstr(eempid)
            If ecl=0 Then
               ecl=0
            End If
            If ecl=0.5 Then
               ecl=0
            End If
            If ecl=1  Then
                ecl=1
            End If
            If ecl=1.5 Then
                ecl=1
            End If
            If ecl=>2 Then
                ecl=2
            End If
        wend [/color]
     Next

Regards,
Praveen raaj.


RE: While Wend condition - ravi.gajul - 06-11-2012

Please use while strcomp(cstr(empid),cstr(eempid))=0

Strings cannot be compared with "=" operator



RE: While Wend condition - raaj123 - 06-11-2012

hi dude,

my string is ASF467 this is for both empid & eempid

Code:
c=strcomp(cstr(empid),cstr(eempid))
        msgbox c

as u told above line it is displaying value as "-1" instead of "0" what to do pls help me.

Code:
while strcomp(cstr(empid),cstr(eempid))=0
when i am using this line my while loop is continuous.


regards,
Praveen raaj.


RE: While Wend condition - ravi.gajul - 06-11-2012

Looks like there is a space in one of the variables value and so is the result -1
Please try
Code:
while strcomp (cstr(trim(eempid)),cstr(trim(empid)))=0
the control enters the while loop and continues as condition always returns 0 if both the values compared are same.Hence some where inside the loop ,change the value of empid or eempid to fail the condition and thus exit the loop.