<< Click to Display Table of Contents >> Kill (statement) |
Kill FileName
Deletes the given file(s).
You can use wildcard characters such as "*" and "?" in FileName. For example, the following command deletes all files with the file extension "bak":
Kill "*.bak"
See also: RmDir
Example:
Const NumberOfFiles = 3
Sub Main
Dim Msg ' Declare variables
Call MakeFiles() ' Create files
Msg = "Some test files were created. "
Msg = Msg & "Click on OK to delete them again."
MsgBox Msg
For i = 1 To NumberOfFiles
Kill "TEST" & o ' Delete files
Next i
End Sub
Sub MakeFiles()
Dim i, FNum, FName ' Declare variables
For i = 1 To NumberOfFiles
FNum = FreeFile ' Next free file pointer
FName = "TEST" & i
Open FName For Output As Fnum ' Open file
Print #FNum, "This is test #" & i ' Write to file
Print #FNum, "Here comes another "; "line"; i
Next i
Close ' Close all files
End Sub