Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Loop a Control Array Posted by c802ice on 6 Aug 2003 at 1:04 PM
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.






Report
Re: Loop a Control Array Posted by jeffreyhamby on 6 Aug 2003 at 1:47 PM
: 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.


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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.