Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

N00b VB6 question number 2

Options
  • 21-05-2003 10:10am
    #1
    Registered Users Posts: 3,779 ✭✭✭


    Hello :)


    how do you loop all your elements in a control array ?

    I have a control array of lblName set up and want to go through them all.

    I thought

    for i = 0 to UBound(lblName)

    might work but it generats an error

    'expected array'

    please help this newbie :D


Comments

  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    This will do it :

    For i = Label1.LBound To Label1.UBound

    Bear in mind, though, that a control array does not have to have sequential index numbers (e.g. you can create a control array with label1(0) and label1(2) in it, without label1(1) existing.

    So you'll also need some error handling, or some other check to see if the control exists.

    A better bet may be to look at the For Each loop. Check up the help on that...it should tell you everything you need to know.

    jc


Advertisement