Multi-Select items in ListBox from VB (1 Viewer)

BigJimSlade

Registered User.
Local time
Today, 03:24
Joined
Oct 11, 2000
Messages
173
Hey, Big Jim here...

I was wondering if there was a way to select multiple items from a list box from VB.

For example, say I have "A", "B", "C", and "D" in a listbox. (I have MultiSelect already turned on.) Now, I want my VB code to highlight both "A" and "B" in the listbox. How would I do this?

I guess I am looking for the VB way to hold down the ctrl key while I select multiple items.

Thanks in advance....Big Jim
 

Jack Cowley

Registered User.
Local time
Today, 03:24
Joined
Aug 7, 2000
Messages
2,639
This code will highlight the first two items in the list:

Dim i As Integer

For i = 1 To 2
Me.ListBoxName.Selected(i) = True
Next i
 

BigJimSlade

Registered User.
Local time
Today, 03:24
Joined
Oct 11, 2000
Messages
173
Thanks, Jack!

That really helped. I must remind anyone trying to do this that you have to have the multi-select property for the list box set to yes or it will not work.
 

AlexanderX

New member
Local time
Today, 03:24
Joined
Mar 20, 2001
Messages
6
While we're on this subject - I have a related question I'm hoping someone can help me with.

I'm creating a form that needs to include a multi-select list-box that allows users to enter new records. I haven't yet found a way, however, to commit values selected via this list box into its bound field.

Is it possible to commit multiple selections from a list box into a single field? If so, how can this be achieved?

Any insights into this dilemna are greatly appreciated.

Thanks! - AlX
 

Users who are viewing this thread

Top Bottom