codice:
Private Sub Form_Load()
Dim file() As String
   file() = Elencafile("c:\")
End Sub

Private Function Elencafile(sDirectory As String) As String()
'elenca i file in una directory
'il primo elemento dell'array restituito è vuoto
Dim files() As String
Dim stemp As String
    ReDim files(0)
    stemp = Dir$(sDirectory)
    Do Until stemp = ""
        If stemp <> "." And stemp <> ".." And GetAttr(sDirectory & stemp) <> vbDirectory Then
            ReDim Preserve files(UBound(files) + 1)
            files(UBound(files)) = stemp
        End If
        stemp = Dir()
            
    Loop
    Elencafile = files
End Function