Example - FreeFile Function

To use this example, create a folder named e1 on your c:\ drive. When you run the script, it then creates three files TEST1, TEST2, TEST3 in that folder. It then reads the contents of the first TEST1 file.

Sub Main()
    Dim Mx, FileNumber
    For Mx = 1 To 3
        FileNumber = FreeFile
        Open "c:\e1\TEST" & Mx For Output As #FileNumber
        Write #FileNumber, "This is a sample."
        Close #FileNumber
    Next Mx
    Open "c:\e1\test1" For Input As #1
    Do While Not EOF(1)
        MyStr = Input(10, #1)
        MsgBox MyStr
    Loop
    Close #1
End Sub