Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through Constants 1

Status
Not open for further replies.

intrepid101

Programmer
Aug 8, 2001
13
0
0
US
If I set up my Constants as

Const status1 = "Under Construction"
Const status2 = "Active (Recruiting)"
Const status3 = "Active (Closed)"
Const status4 = "In-Active"
Const status5 = "DisBanned"

Can I then loop through them to add to a combobox

For idx = 1 To 5
cmbStatus.AddItem (Status & idx)
'^ Obviously does not work says 'status' not defined
Loop

or do I need to use the direct method:

cmbStatus.AddItem "Under Construction"
cmbStatus.AddItem "Active (Recruiting)"
cmbStatus.AddItem "Active (Closed)"
cmbStatus.AddItem "In-Active"
cmbStatus.AddItem "Disbanned"
 
I think it would be easier and less code to do the traditional add.item method
use this
cmbStatus.AddItem "Under Construction"
cmbStatus.AddItem "Active (Recruiting)"
cmbStatus.AddItem "Active (Closed)"
cmbStatus.AddItem "In-Active"
cmbStatus.AddItem "Disbanned"
or use this

Private Sub Form_Load()
With cmbstatus
.AddItem ("Under Construction")
.AddItem ("Active (Recruiting)")
.AddItem ("Active (Closed)")
.AddItem ("In-Active")
.AddItem ("DisBanned")
End With
 
Ok thanks that was what I was thinking. Which is better, it forces me to make a cfg file and load the list off it, which is what I needed to do but was getting lazy. :)

Thanks
Peace Out
Scott
 
I think you can also create an enumeration, and do a for..each on it (haven't tried this myself).

Chip H.
 
As you have already set up constants, why not save time and use constants for what they are suppoed to be used for :


cmbStatus.AddItem status1
cmbStatus.AddItem status2
cmbStatus.AddItem status3
cmbStatus.AddItem status4
cmbStatus.AddItem status5

Chris Dukes

 
[tt]
Const csStatusList = &quot;Under Construction<REC>&quot; _
& &quot;Active (Recruiting)<REC>&quot; _
& &quot;Active (Closed)<REC>&quot; _
& &quot;In-Active<REC>&quot; _
& &quot;DisBanned&quot;

Dim arr, s
arr = SPLIT(csStatusList, &quot;<REC>&quot;)
for each s in arr
cmbStatus.AddItem s
next s
[/tt]

Wil Mead
wmead@optonline.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top