|
-
October 16th, 2003, 10:25 AM
#1
looping past index limit
Hey Kids,
THis is a little strange, but probably simple. I am doing a standard loop, but it keeps going past the limit...
Dim FlowRaster(1 To 12) As IRaster
For i = 1 To 12
do some **** here
Next i
i keeps trying to process a 13th entry???? Any ideas?
The reason I set the lower bound index to 1 instead of the usual 0, is just for easier interpretation, these are months.
Thanks
-
October 16th, 2003, 10:36 AM
#2
You sure you do not change value of "i" inside the for next?
To be sure:
before next statement, write:
debug.print "i= " & i
and look at values.
it should start with 1 and end with 12
(of course, after the next statement -exiting the next - it should be = 13)
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
October 16th, 2003, 11:03 AM
#3
index loop error
Hey Cimp
no I don't change anything, and I have checked, the value definetly changes to 13 inside the loop. here is all my code
Dim FlowRaster(1 To 12) As IRaster
For i = 1 To 12
Set FlowRaster(i) = SWFFunctions.SetFlows(pRaster3, "Flow_Rcl", i, outputpath)
Next i
Just a little strange, huh?????
-
October 16th, 2003, 11:07 AM
#4
no I don't change anything, and I have checked, the value definetly changes to 13 inside the loop.
I assume because you say this, that after the loop completes, the value of i is 14?
-
October 16th, 2003, 11:17 AM
#5
How many times to you loop really ? The only reason i see it may be doing this is that i is passed by reference to SWFFunctions.SetFlows and SetFlows increment your value of i and return the new value.
if you can change the definition of SetFlow be sure to set ByVal for the i parameter.
If that cannot be done, use another var to pass the i value to SetFlows.
-
October 16th, 2003, 11:29 AM
#6
Set FlowRaster(i) = SWFFunctions.SetFlows(pRaster3, "Flow_Rcl", i, outputpath)
you sure i is not changed in setFlows (Heulsay probably got the matter...) ?
you could code also
Code:
Dim FlowRaster(1 To 12) As IRaster
dim tmpCounter as integer
For i = 1 To 12
tmpCounter=i
Set FlowRaster(i) = SWFFunctions.SetFlows(pRaster3, "Flow_Rcl", tmpCounter, outputpath)
Next i
if you cannot change the byref of the method...
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
October 16th, 2003, 12:29 PM
#7
Cimp wins
Cimper,
You are the man, I foolishly was using i in another loop in the called function, so that was superseding my passed i. I must expand my alphabet.
Thanks
-
October 16th, 2003, 03:51 PM
#8
Heulsay deserve some credit, too...
...LOL...It was not a race, but in any case Heulsay said it as first (byref variable, is not it?)
("give Caesar what is of Caesar"... )
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|