Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
While Wend condition
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
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.
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Please use while strcomp(cstr(empid),cstr(eempid))=0

Strings cannot be compared with "=" operator
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
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.
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to verify the drop down values based on condition santhoshmscsoftware 1 2,912 05-04-2016, 11:28 PM
Last Post: supputuri
  Condition/Outcome Branching within Script danielrose01 3 3,420 06-13-2012, 10:29 AM
Last Post: sshukla12
  if condition throwing type mismatch error rrdamuluri 2 4,109 11-04-2010, 10:51 PM
Last Post: rrdamuluri
  Can we use checkpoint as a condition statement? riteshgpt 4 9,819 04-28-2010, 08:49 PM
Last Post: riteshgpt
  Can we use Flower Brackets while using If...Else condition? dinesh_d_r 1 3,029 11-26-2008, 10:23 AM
Last Post: yaron.assa

Forum Jump:


Users browsing this thread: 1 Guest(s)