For Each ... Next ... Step?

  • Thread starter Thread starter jimcarroll via AccessMonster.com
  • Start date Start date
J

jimcarroll via AccessMonster.com

Forgive me if this has been covered somewhere else, or it it's well-known.

Basic had a construct for loops: for each, next, step where "step" was an
optional increment to the loop's iteration counter.

Does such a construct exist in VBA, and if so, must "step" be an integer, or
can it be a decimal value?

Thanks.

Jim
 
My apologies:
Basic had a construct for loops: for each, next, step where "step" was an
optional increment to the loop's iteration counter.

This is in error; I've confabulated two different things.

I meant For -- Next -- Step (not For Each).

Sorry for the lapse.

Jim
 
Yes, VBA has the construct

For lngCounter = 1 to Somenumber Step n

Next lngCounter

As far as I know the step has to be an integer, but then I've never tried using
non-integer values
 
jimcarroll via AccessMonster.com said:
My apologies:


This is in error; I've confabulated two different things.

I meant For -- Next -- Step (not For Each).

Sorry for the lapse.

the increment (Step) can be a non-integer value.

Tom Lake
 
Actually it has both.

FOR EACH for use when looping through objects in a collection
FOR for use when executing loops in general.

Also, if you're familar with any version of BASIC, you should be about
75% (or more) familar with VBA. The difference being the various things
unique to Microsoft, the application itself and/or dealing with a visual
environment. When I started playing with it back in '95 (YIKES!) I
didn't have any major problems learning it - despite the fact that I
hadn't even done *any* programming since '87 or earlier. (Of course, I
am a genius so that might have had something to do with it.)

David H
 
Back
Top