Siebel VB Language Reference > VB Language Reference >
Kill Statement
Deletes files from a hard disk or floppy drive. Syntax
Kill pathname
|
|
pathname |
A string expression that represents a valid DOS file specification |
Returns
Not applicable Usage
The pathname specification can contain paths and wildcards (? and *). Kill deletes files only, not folders. To delete folders, use the RmDir function. Example
This example prompts a user for an account number, opens a file, searches for the account number, and displays the matching letter for that number. The second subprogram, CreateFile , creates the file c:\temp001 used by the main subprogram. After processing is done, the first subroutine uses Kill to delete the file. (general) (declarations) Option Explicit Declare Sub CreateFile Global x as Integer Global y(100) as String
Sub CreateFile ' Put the numbers 1-10 and letters A-J into a file Dim startletter Open "c:\temp001" for Output as #1 startletter = 65 For x = 1 to 10 y(x) = Chr(startletter) startletter = startletter + 1 Next x For x = 1 to 10 Write #1, x,y(x) Next x Close #1 End Sub
Sub Button_Click Dim acctno as Integer Dim msgtext Call CreateFile i: acctno = 6 If acctno<1 Or acctno>10 then Goto i: End if x = 1 Open "c:\temp001" for Input as #1 Do Until x = acctno Input #1, x,y(x) Loop msgtext = "The letter for account number " & x & " is: _ " & y(x) Close #1 kill "c:\temp001" End Sub
See Also
FileAttr Function FileDateTime Function GetAttr Function RmDir Statement
|