Example - Close Statement

  1. Sub Main

    1. Open "c:\test.txt" For Input As #1

      Do While Not EOF(1)

      1. MyStr = Input(10, #1)

        MsgBox MyStr

      Loop

      Close #1

     

    End Sub

 

  1. Sub Make3Files ()

    1. Dim I, FNum, FName ' Declare variables.

      For I = 1 To 3

      1. FNum = FreeFile  ' Determine next file number.

        FName = "TEST" & FNum

        Open FName For Output As FNum ' Open file.

        Print #I, "This is test #" & I ' Write string to file.

        Print #I, "Here is another "; I

      Next I

      Close ' Close all files.

    End Sub