IMO
Now Known as ___
- Local time
- Today, 18:35
- Joined
- Sep 11, 2002
- Messages
- 723
Hi All,
I'm using this code to view the contents of a directory in a listbox :
Private Sub Form_Open(Cancel As Integer)
Dim strFile As String, strRowSource As String
strFile = Dir("C:\MY FOLDER NAME\")
strRowSource = strRowSource & strFile
Do Until strFile = ""
strFile = Dir
strRowSource = strRowSource & strFile & ";"
Loop
Me.List20.RowSource = Left(strRowSource, Len(strRowSource) - 1)
End Sub
It works fine if there are files in the folder but if the folder is empty I get the following message :
Run-time error '5'
Invalid procedure call or argument.
Could someone tell me what I'm doing wrong.
Thanks in advance
IMO
I'm using this code to view the contents of a directory in a listbox :
Private Sub Form_Open(Cancel As Integer)
Dim strFile As String, strRowSource As String
strFile = Dir("C:\MY FOLDER NAME\")
strRowSource = strRowSource & strFile
Do Until strFile = ""
strFile = Dir
strRowSource = strRowSource & strFile & ";"
Loop
Me.List20.RowSource = Left(strRowSource, Len(strRowSource) - 1)
End Sub
It works fine if there are files in the folder but if the folder is empty I get the following message :
Run-time error '5'
Invalid procedure call or argument.
Could someone tell me what I'm doing wrong.
Thanks in advance
IMO