Re: how do I select all items in a file list with code?




"Ken Macksey" <KenMacksey@xxxxxxxxx> wrote in message
news:%23SdPpPXkFHA.572@xxxxxxxxxxxxxxxxxxxxxxx
>I am using the Drive listbox, dir listbox and file listbox. Once I have
>selected the drive and Dir, I want to automatically select all of the files
>in the file listbox with code.
>
> All help appreciated.


What have you tried? If you haven't tried, you should always do so first.
If you encounter problems, than ask for help regarding that problem. It's
to YOUR advantage to always try first because that's how you learn. If
you're always just given the code, you won't learn nearly as much. With
that said, I'll give you the code against my better judgement. Make sure the
FileListBox's MultiSelect property is set at design-time to either 1 or 2.

Private Sub Dir1_Change()

Dim Index As Long

File1.Path = Dir1.Path

For Index = 0 To File1.ListCount - 1
File1.Selected(Index) = True
Next

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub


--
Mike
Microsoft MVP Visual Basic


.


Loading