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

Long List (1900 Characters) in a List Box Gives me an error

Status
Not open for further replies.

Maturi

IS-IT--Management
Oct 9, 2003
81
0
0
GB
Hi

Problem
The user selects an item from a list box (LB1) – this is list of files found in a given directory – so it could be a list of 5 or 500.

StrPack is a string of filenames separated by ‘;’. This works fine for a small number of files. But if the string is over about 1900 characters I get an error when I try to do

Me!LB1.RowSource = strPack


Possible Solutions
1 – find a way to increase the capacity of LB1 (unlikely)
2 – copy all the filenames into a table and make the table the ‘Row Source ‘. Can’t do this as I have multiple users so managing unique tables for each user is not attractive
3 – Create an array in VB to hold the list of items and then make the array the ‘Row Source’ for the list box.

Option 3 is appealing but …
1- I don’t know how to handle arrays in VB
2- I don’t know how to assign an array to a list box’s Row Source


Any suggestions would be appreciated

Alternatively is there a simple add-on or control that list the files in a given directory?

Thanks
 
Have a look in the VBA help for the RowSourceType property to discover how to write your own function populating the ListBox.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top