Alright, in the attached image, you can see I have a drive listbox, a dirlist box, and a file listbox... I need the dirlistbox to display the folders in the selected drive in the drive list box and I need the file list box to display the files in the selected folder... How would this be done?
Haikus are easy.
But sometimes they don't make sense.
Refrigerator.
Private Sub Form_Load()
Drive1.Drive = "C:"
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
works perfectly, except or one thing... if there isnt anything there, and you click the drive, it gives yu and error... also, is there a way I can get a command button to open the selected file in the filelist?
Haikus are easy.
But sometimes they don't make sense.
Refrigerator.
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
On Error GoTo ErrRun
With CommonDialog1
.CancelError = True
.DialogTitle = "Choose a file to run"
.ShowOpen
End With
ShellExecute Me.hwnd, vbNullString, File1.FileName, vbNullString, "C:\", SW_SHOWNORMAL
Exit Sub
ErrRun:
MsgBox Err & " " & Error
End Sub
That was an example using the CommonDialog. You aren't using it.
When a piece of code is posted in response to a question it is generally NOT going to work as posted. There will always be something you have to change to fit it into your program, but, the underlying content of the code will generally work.
You need to modify my example to fit your program.