Loop a Control Array

Help! I'm a beginner and I'm trying to loop a control array as follows:

Dim intIndex as Integer
For intIndex = 0 to 3
lblRRLoad(Index) = Int(sngRRLoad)
If lblRRLoad (Index) <> sngRRload then
lblRRload(Index)=lblRRLoad(Index)+1
End If
Next intIndex

lblRRLoad(0) trough lblRRLoad(3) have a value stored in them that was previously calculated in the same cmdCalc subroutine. I want the application to loop through the control array. In other words, the first time through I want to look like this:

lblRRLoad(0) = Int(sngRRLoad)
If lblRRLoad(0)<>sngRRLOad
then lblRRLoad(0) = lblRRLoad(0)+1

then go through and do it for each Index from 0 to 3. When I try to run it I get an error that"Index" is not defined.






Comments

  • [italic]: Help! I'm a beginner and I'm trying to loop a control array as follows:
    :
    : Dim intIndex as Integer
    : For intIndex = 0 to 3
    : lblRRLoad(Index) = Int(sngRRLoad)
    : If lblRRLoad (Index) <> sngRRload then
    : lblRRload(Index)=lblRRLoad(Index)+1
    : End If
    : Next intIndex
    :
    : lblRRLoad(0) trough lblRRLoad(3) have a value stored in them that was previously calculated in the same cmdCalc subroutine. I want the application to loop through the control array. In other words, the first time through I want to look like this:
    :
    : lblRRLoad(0) = Int(sngRRLoad)
    : If lblRRLoad(0)<>sngRRLOad
    : then lblRRLoad(0) = lblRRLoad(0)+1
    :
    : then go through and do it for each Index from 0 to 3. When I try to run it I get an error that"Index" is not defined.
    [/italic]

    Change "index" to intIndex inside lblRRLoad(). You're using intIndex to count from 0 to 3, and it will hold the index value for those objects inside the loop.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion