G
Guest
Hi Everyone,
I want to fill a lost box with all directories in c:\. (Below is my code) I
am running into a problem with moving to the next name - It finds the first
just fine (Documents and Settings), but hands up on the second loop when it
gets to "strName = Dir" error "Invalid procedure call or argument". Any
ideas?
Dim strDate As String
Dim strPath As String
Dim strName As String
lstResult.RowSource = ""
' get the date that the user entered.
txtDate.SetFocus
strDate = txtDate.Text
' get the directory that they want to search in.
txtDir.SetFocus
strPath = "c:\"
strName = Dir(strPath, vbDirectory)
' While we are still in a directory
Do While strName <> ""
' Leave out the current directory or a previous one
If strPath <> "." And strPath <> ".." Then
' check to make sure that this is a real directory
If (GetAttr(strPath & strName) And vbDirectory) = vbDirectory Then
' it is a diretory, so list the name of it in the listbox
lstResult.RowSource = lstResult.RowSource & strName & ";"
End If
End If
' Call Dir again without arguments to return the next directory.
strName = Dir
Loop
lstResult.Requery
I want to fill a lost box with all directories in c:\. (Below is my code) I
am running into a problem with moving to the next name - It finds the first
just fine (Documents and Settings), but hands up on the second loop when it
gets to "strName = Dir" error "Invalid procedure call or argument". Any
ideas?
Dim strDate As String
Dim strPath As String
Dim strName As String
lstResult.RowSource = ""
' get the date that the user entered.
txtDate.SetFocus
strDate = txtDate.Text
' get the directory that they want to search in.
txtDir.SetFocus
strPath = "c:\"
strName = Dir(strPath, vbDirectory)
' While we are still in a directory
Do While strName <> ""
' Leave out the current directory or a previous one
If strPath <> "." And strPath <> ".." Then
' check to make sure that this is a real directory
If (GetAttr(strPath & strName) And vbDirectory) = vbDirectory Then
' it is a diretory, so list the name of it in the listbox
lstResult.RowSource = lstResult.RowSource & strName & ";"
End If
End If
' Call Dir again without arguments to return the next directory.
strName = Dir
Loop
lstResult.Requery