Example - Kill Statement

  1. Const NumberOfFiles = 3

     

    Sub Main ()

    1. Dim Msg' Declare variable.

      Call MakeFiles()' Create data files.

      Msg = "Several test files have been created on your disk. You may see "

      Msg = Msg & "them by switching tasks. Choose OK to remove the test files."

      MsgBox Msg

      For I = 1 To NumberOfFiles

      1. Kill "TEST" & I ' Remove data files from disk.

      Next I

    End Sub

     

    Sub MakeFiles ()

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

      For I = 1 To NumberOfFiles

      1. FNum = FreeFile' Determine next file number.

        FName = "TEST" & I

        Open FName For Output As FNum' Open file.

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

        Print #FNum, "Here is another ";"line";I

      Next I

      Close' Close all files.

      Kill FName

    End Sub