sending a blank array in and getting a full array out

i would like to fill a blank array with the names of all files in a given directory. I am getting an out of bounds run time exception

please advise

Dim Arr() As String

// function call
GetDirFiles(path, Arr)

sub GetDirFiles(iPath As String, ByRef RtnArr() As String) 
  Dim rtnStr As String
  Dim appFolder As FolderItem = New FolderItem(iPath, FolderItem.PathTypeShell)
  If appFolder Is Nil Then
  End If
  Dim count As Integer  = appFolder.Count
  For i As Integer = 1 to count
    Dim f As FolderItem = appFolder.Item(i)
    If f <> Nil Then

        // This line is getting an error during run time "out of bounds exception"
        RtnArr(i) = f.Name

    End If
end sub
RtnArr().append f.Name

hi Roger

When do a Tab lookup on my array IE
the append option does not come up

RtnArr(i).append value
An Error is produced “String has no name append”

RtnArr.append f.Name

Don’t put an element value in your array. When you specify append, you are just adding it to the end of the array, not to a specific element. RtnArr() NOT RtnArr(i)
Since you will not know the value of appFolder.count before hand, append is the only way you should handle this.

…as Axel pointed out, the () after the array name is optional. That’s a coding style choice and I choose to add the ().

ok great
it works

thank you all …