I have been trying to learn some of the commands and methods of VB and one

shown was FreeFile which I understand gets the next available file number
to store data.

The following is part of suggested code to play with, but won't execute
because it has a bad file name or number.

Does that mean that the File Name which is a concatenation of a literal
"Test" and Index number were not "Dim"med or perhaps the file number
should havew been a pathway?

Would appreciate any suggestions or comments


Private Sub Main()

For MyIndex = 1 To 5 ' Loop 5 times
FileNumber = FreeFile(0) ' Get unused file numbers

Open "Test" & MyIndex For Output _
As #FileNumber
Write #FileNumber, "This is a Sample"
Close #FileNumber
Next MyIndex

End Sub