List Box Control

R

RAM

I have a list box control named FileList. The list box contains the
location of multiple video and or images on my C drive. I have eight video
displays named MP1 thru MP8.
The idea is to populate the image controls with the video or image while
automatically moving through the listbox. The first image represented within
the listbox populates all the image controls. I have the following code to
select the image and cycle through the list box.

If FileList.ListIndex = 0 Then
MP1.FileName = FileList.Value
LCN = 1
End If
If FileList.ListCount > 0 And FileList.ListCount <> 2 Then
FileList.ListIndex = 1 ‘This cycles the list box selection
End If
If FileList.ListCount > 1 Then
MP2.FileName = FileList.Value ‘I thought by setting the index to 1 that the
FileList.Value would change to the value represented by the index 1. But it
does not change.
LblM1 = FileList.Value
LCN = 2
End If
 
S

strive4peace

Are you wanting to cycle through just selected items in the listbox or
ALL items regardless of whether they are selected or not?

if All items, what is the RowSource of the listbox?


Warm Regards,
Crystal

*
:) have an awesome day :)
*
 
R

RAM

The List Box is unbound and used as a value list. I populate it through a
dialog control (Set fDialog =
Application.FileDialog(msoFileDialogFilePicker). The loading of the List Box
works OK. I would like the option to cycle through all the files listed in
the List Box and if I could have the option, I would like to selectively pick
from the List Box .

Thank you for your response.

Bob
 
S

strive4peace

Hi Bob,

loop through listbox items selected

'~~~~~~~~~~~~~~~~
If Me.listbox_controlname.ItemsSelected.Count = 0 Then
MsgBox "You have not picked anything",,"Nothing Selected"
exit sub
End If

dim varItem as variant

For Each varItem In me.listbox_controlname.ItemsSelected
debug.print me.listbox_controlname.ItemData(varItem)
Next varItem
'~~~~~~~~~~~~~~~~


Warm Regards,
Crystal

*
:) have an awesome day :)
*
 
S

strive4peace

you're welcome, Bob ;) happy to help

Warm Regards,
Crystal

*
:) have an awesome day :)
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top