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

Can I use data in array to load list box?

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I use the following code to open a text file and put he first 8 characters of each line into the arrayFees. Is it possible to set the control source of an unbound listbox to the values in the array? If there were ten values in the array they would be ten listing in the listbox. The last statement of this code leaves the list box empty. Thanks.

Open File For Input As #1
n = 1
Dim Record As String

Do While Not EOF(1)
Line Input #1, Record
arFees(n) = Mid(Record, 1, 8)
n = n + 1
Loop

Me.lstRef.ControlSource = "arFees"
 
Sure you can! =]

Make sure the listbox is set for Value List, and you can use lstRef.AddItem.

Open File For Input As #1
n = 1
Dim Record As String

Do While Not EOF(1)
Line Input #1, Record
arFees(n) = Mid(Record, 1, 8)
lstRef.AddItem arFees(n)
n = n + 1
Loop

-Pete
 
Brilliant!

Thanks Pete! Works great.

Eddy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top