FreeFile function
FreeFile
Returns an integer that is the next available file handle to be used by the Open statement.
Example
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