L'ho scritto in questo modo:



Sub ElencaFolders(folderOr As String, ByRef fso)
Dim f, cartella, SubF
Static i As Long
Dim NewDir As String

Set f = fso.GetFolder(folderOr)
Call ElencaFiles(folderOr, fso)
Set SubF = f.SubFolders
If (SubF.Count > 0) Then
For Each cartella In SubF
NewDir = fso.BuildPath(folderOr, cartella.Name)
Call ElencaFolders(NewDir, fso)
Next
End If
End Sub

Sub ElencaFiles(folderOr As String, ByRef fso)
Dim folderO, insiemeFiles, file, str

Set folderO = fso.GetFolder(folderOr)
Set insiemeFiles = folderO.Files
If insiemeFiles.Count > 0 Then
For Each file In insiemeFiles
str = str + folderOr + file.Name + vbCrLf
Next
End If
End Sub

Private Sub Command1_Click()
Dim str As String
Set fso = CreateObject("Scripting.FileSystemObject")
Call ElencaFolders("C:\Programmi", fso)
Text1.Text = str
End Sub


Però il text rimane vuoto dopo qualche minuto di caricamento del programma, dove ho sbagliato?