Forum Discussion

mesg2anil's avatar
mesg2anil
Regular Contributor
13 years ago

Object Name Incrementing...

Hi,



I need help on incrementing the number within the object name... I'm using below code...



    For i = 1 to 5

        Browser.Item("gvCarParkDetails_ctl02_chkIsLease").Click

    Next



Here, within the object name "Item("gvCarParkDetails_ctl02_chkIsLease")" u can find "02", each time for loop increments, I want 02 to get incremented as well like, 02, 03, 04, 05 etc...



Any ideas here please??

3 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    For i = 1 to 5

        Browser.Item("gvCarParkDetails_ctl0" & i & "_chkIsLease").Click

    Next
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Gennadiy,



    Thank you for replying...

    It is working superb till i = 09, when i = 10 then the object name is becoming ctl010, where as in application it will be ctl10, so how to manage this '0'?

    Any suggestion on this please?
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Gennadly,



    I did below change and it is working as I expected... :)




    For i = 2 to 20

        If i < 10 Then

            popupwnd.document.all.Item("gvCarParkDetails_ctl0" &i &"_chkIsLease").Click

        Else

            popupwnd.document.all.Item("gvCarParkDetails_ctl" &i &"_chkIsLease").Click

        End If

    Next



    Thank you for the idea!!


    i = 2 20 i < 10         popupwnd.document.all.Item("gvCarParkDetails_ctl0" &i &"_chkIsLease").Click        popupwnd.document.all.Item("gvCarParkDetails_ctl" &i &"_chkIsLease").Click Thank you for the idea!!