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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like to consolidate the fol

Status
Not open for further replies.

illini

Technical User
Aug 2, 2002
89
FR
I would like to consolidate the following code:

F1 = ListBox.ItemData(1)
F2 = ListBox.ItemData(2)
F3 = ListBox.ItemData(3)

Into something like this…

For y = 1 to 3
F(y) = ListBox.ItemData(y)
Next y

What do I need to do to set-up F(y)?
-illini
 
You did not indicate what type of data is going to be stored from the ListBox so I just assumed Text.

Dim y as integer
Dim F(3) as String
'Use this if Numeric
'Dim F(3) as Long
For y = 1 to 3
F(y) = ListBox.ItemData(y)
Next y

Let me know if you need more explaination.
Bob Scriver
 
Bob,

I tried both versions (Dim y As String & Dim y as Long) with no success.

Using Dim y As String, I got a Run-time error '9' (Subscript out of range).

Using Dim y As Long, I got a Run-time error '13' (Type mismatch) -illini
 
Do not change this one. Dim Y as Integer

This statement you change depending upon the type of data in the ListBox:
Dim F(3) as String if the data is text.
Dim F(3) as Long if the data is an Numeric Integer.
Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top