|
-
Mar 22nd, 2004, 09:02 AM
#1
Thread Starter
Lively Member
-
Mar 22nd, 2004, 09:12 AM
#2
Where are the numbers coming from?
If your gonna do the string approach, use a delimeter. Then use the Split() function on the string, you'll get an array from that. You can then iterate through the array, adding the array elements to the list.
-
Mar 22nd, 2004, 09:32 AM
#3
Thread Starter
Lively Member
The numbers are fixed values obtained when a user selects an option from a first Listbox.
So, depending on what the user selects from the first Listbox, a group of numbers are slected and these are used to create the contents of a second Listbox.
Old divers never die, they just go down on old wrecks 
-
Mar 22nd, 2004, 09:45 AM
#4
Frenzied Member
Are the values in the first list box static? Will they always put the same numbers in the second list box?
If so, just do a simple routine to place those numbers in the second list box when that option is chosen in the first one.
-
Mar 22nd, 2004, 09:45 AM
#5
So the first listbox contains numeric values? Or we're you refering to the index range of the selected values in the first listbox?
If so then iterate through the items of the first listbox. If List1.Selected = True then add the List1.ListIndex to the second listbox.
-
Mar 22nd, 2004, 10:08 AM
#6
Thread Starter
Lively Member
To elaborate.
Listbox 1 has fixed options: MenuItem1, menuItem2.... MenuItem11 etc.. These are fixed options.
When the user selects say MenuItem1, using the Case Select statement a number of fixed numbers (10, 12, 14, 16, ....45) are used to create the MenuItems for a second list box.
So, MenuItem1 = 10, 12, 14, 16, 20 ........ 45
Menuitem 2 = 18, 20, 20 ....... 40
.
.
MenuItem11 = 20, 30, 40 ....................
etc.
All these numbers and menuitems are fixed, nothing will ever vary.
Old divers never die, they just go down on old wrecks 
-
Mar 22nd, 2004, 10:33 AM
#7
Frenzied Member
Then in that Case statement, add those numbers to the second listbox with AddItem.
You also mixed 2 controls in the same sentance in your first post. You said a ComboListBox.
Is it a ComboBox or a ListBox for the 2nd one?
-
Mar 22nd, 2004, 10:41 AM
#8
Thread Starter
Lively Member
Then if I have 11 MenuItems in Listbox1 I am going to have 11 AddMenu.item routines to generate the second Listbox. If I can generate a String from any of the 11 options I just need to have 1 AddMenu.item routine to populate the second Listbox. i.e. use a loop: For i = 1 to len(MenuItemString) Next.
Although this is quite a straightforward thing to do, I want to use the minimum of code as I will have a large number of similar operations to set up Multiple Listboxes.
Regards.
Old divers never die, they just go down on old wrecks 
-
Mar 22nd, 2004, 10:45 AM
#9
Frenzied Member
Then generate a comma delimited string and use split and read it into an array. Then add each item from the array.
-
Mar 22nd, 2004, 10:45 AM
#10
Thread Starter
Lively Member
Sorry Brian, I didn't answer one of your questions. These are Combo boxes selected as style 2 (dropdown lists).
Old divers never die, they just go down on old wrecks 
-
Mar 22nd, 2004, 10:49 AM
#11
Thread Starter
Lively Member
I wasn't aware of the Split function. This possibly will do the trick, I will check it out later.
Thanks for your comments guys, much appreciated.
Regards.
Old divers never die, they just go down on old wrecks 
-
Mar 22nd, 2004, 10:53 AM
#12
Pass the comma delimeted string (or the array after split) as a parameter for the procedure that will populate the second listbox.
-
Mar 22nd, 2004, 11:04 AM
#13
Frenzied Member
Example
VB Code:
Dim mystring As String
Dim myarray() As String
Dim x As Integer
mystring = "12,34,56,78,90"
myarray = Split(mystring, ",")
For x = 0 To UBound(myarray, 1)
Combo1.AddItem myarray(x)
Next x
That will load 12, 34, 56, 78 and 90 as items in the combo1 box.
-
Mar 22nd, 2004, 03:22 PM
#14
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|