Proper Syntax

K

kealaz

Hello,
In a bit of code that I got from this site, there is this line.

For I = 1 To 6

Which tells the scrip to use the values in column 1 thru six of my combo
box. I just want to use columns 2, 4, and 6. What is the proper syntax to
use to make this change. I have tried 2, 4, 6 but does not work. Actually
I've tried several things. 2 or 4 or 6 does not work either, as I would like
3 values at my result, not just 1.

Thank you for all your help with this.
 
M

M Skabialka

Try a select statement:

For I = 1 To 6
Select Case I
Case 2
'do something
Case 4
'do something
Case 6
'do something
Case Else
'don't do anything here
End Select
 
D

Dirk Goldgar

kealaz said:
Hello,
In a bit of code that I got from this site, there is this line.

For I = 1 To 6

Which tells the scrip to use the values in column 1 thru six of my combo
box. I just want to use columns 2, 4, and 6. What is the proper syntax
to
use to make this change. I have tried 2, 4, 6 but does not work.
Actually
I've tried several things. 2 or 4 or 6 does not work either, as I would
like
3 values at my result, not just 1.

Thank you for all your help with this.


If you look in the Visual Basic Language section of the help file for "For
.... Next Statement", you'll find complete documentation of this statement.
Reading that, you'll see that you could write:

For I = 2 to 6 Step 2

to accomplish what you want.
 
K

Kaj Julius

kealaz said:
Hello,
In a bit of code that I got from this site, there is this line.

For I = 1 To 6

Which tells the scrip to use the values in column 1 thru six of my combo
box. I just want to use columns 2, 4, and 6. What is the proper syntax
to
use to make this change. I have tried 2, 4, 6 but does not work.
Actually
I've tried several things. 2 or 4 or 6 does not work either, as I would
like
3 values at my result, not just 1.

Thank you for all your help with this.

Try
For I = 2 To 6 Step 2
 
K

kealaz

Thank you VERY much Dirk. This worked great!

Dirk Goldgar said:
If you look in the Visual Basic Language section of the help file for "For
... Next Statement", you'll find complete documentation of this statement.
Reading that, you'll see that you could write:

For I = 2 to 6 Step 2

to accomplish what you want.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Top