
In the Visual Basic 6 code fragments below are included in the Code-VB fragments library. Fragments are snippets of code you can insert in your procedures.Each item between braces correspond to a variable of the given type.They are replaced with the new or existing variables by Fragment Builder in Code-VB tools.
' Create a FileSearch object
Set {Application.FileSearch:FS} = Application.FileSearch
With {Application.FileSearch:FS}
.LookIn = {STRING:FilePath} 'e.g. "c:\myfolder\"
.FileName = {STRING:FileSpec} 'e.g. "text??.txt"
.Execute
End With
' Loop through the files and process them
For i = 1 To {Application.FileSearch:FS}.FoundFiles.Count
Next i
{INTEGER:Fn} = FreeFile
Open {STRING:Filename} For Append Access Write As #{INTEGER:Fn}
Print #{INTEGER:Fn}, {STRING:Output}
Close #{INTEGER:Fn}
{INTEGER:Fn} = FreeFile
Open {STRING:Filename} For Output Access Write As #{INTEGER:Fn}
Print #{INTEGER:Fn}, {STRING:Output}
Close #{INTEGER:Fn}
{INTEGER:Fn} = FreeFile
Open {STRING:Filename} For Input As #{INTEGER:Fn}
{STRING:FileContent} = Input(LOF({INTEGER:Fn}), {INTEGER:Fn})
Close #{INTEGER:Fn}
{INTEGER:Fn} = FreeFile
Open {STRING:Filename} For Input As #{INTEGER:Fn}
Do While Not EOF(Fn)
Line Input #Fn, Line
Loop
Close #{INTEGER:Fn}
