Results 1 to 3 of 3

Thread: recursive function "out of bounds error"

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    25
    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
    give me the handle and I`ll give you the world
    Adam
    junior programmer

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    25
    For i = 1 To UBound(FileList)
    that`a where I get the error
    give me the handle and I`ll give you the world
    Adam
    junior programmer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width