-
I got that function from here but I get ann error "subscript out of range" what`s up with that ??
'recursive folder adding
Public Sub ProcessFiles(d As String)
Playlist.files.AddItem Playlist.files.ListCount + 1 & ". " & d
End Sub
Public Sub ProcessDir(strDir As String)
Dim i
Dim iCount As Integer
Dim Result As String
Dim FileList() As String
iCount = 0
Result = Dir(strDir & "\*.*", vbDirectory)
Do While Result <> "" ' Start the loop.
If Result <> "." And Result <> ".." Then
iCount = iCount + 1
ReDim Preserve FileList(1 To iCount)
FileList(iCount) = strDir & "\" & Result
End If
Result = Dir
Loop
For i = 1 To UBound(FileList)
If (GetAttr(FileList(i)) And vbDirectory) = vbDirectory Then
ProcessDir (FileList(i))
Else
ProcessFiles (FileList(i))
End If ' it represents a directory.
Next
End Sub
-
on what line?
It happens if you
1. assign or try to return a value from an array where the index out of the bounds of it. like a(4)=5 when a(1 to 3)
2. assign or try to return a value from an empty array
3. using ubound or lbound on empty arrays.
-
For i = 1 To UBound(FileList)
that`a where I get the error