Kill command button!!!

I'm trying to create a button on vb 6 and everytime I click on it, it deletes the file, but if I click on it a second time, it gives me an error 53 saying "file not found". Does any1 know a code to fix this? -------------------------------------------------------------------------------------Here's the code im using:

: I'm trying to create a button on vb 6 and everytime I click on it, it deletes the file, but if I click on it a second time, it gives me an error 53 saying "file not found". Does any1 know a code to fix this? : -------------------------------------------------------------------------------------: Here's the code im using:: : Private Sub Command2_Click(): Kill "C:/WINDOWS/Temp/": End Sub: : -------------------------------------------------------------------------------------: Tnx.:

I understand the following from your message:If C:WindowsTemp does not exist, you get an error message, telling you that it is not there. To get rid of this problem, add the following code to the first line to the Sub-procedure: On Error Resume Next

What this does is tell the compiler to ignore the error and simply go to the next line of code. To learn more about this, see help on the Internet about "Error handling"

: : Private Sub Command2_Click(): : Kill "C:/WINDOWS/Temp/": : End Sub: : I'm not sure, but maybe this code kills the directory, or what's in it, and then there is nothing more to kill, so it generates an error.: : If the problem is that, you have to insert a code that controls if there is a directory with that name, or if the directory is not empty.: : If that doesn't work try with: : Private Sub Command2_Click(): On Error GoTo EndOfSub: Kill "C:/WINDOWS/Temp/": EndOfSub:: End Sub: : It's not so elegant, but better than nothing...:

: : Private Sub Command2_Click(): : Kill "C:/WINDOWS/Temp/": : End Sub: : I'm not sure, but maybe this code kills the directory, or what's in it, and then there is nothing more to kill, so it generates an error.: : If the problem is that, you have to insert a code that controls if there is a directory with that name, or if the directory is not empty.: : If that doesn't work try with: : Private Sub Command2_Click(): On Error GoTo EndOfSub: Kill "C:/WINDOWS/Temp/": EndOfSub:: End Sub: : It's not so elegant, but better than nothing...:

lol.... the only way you could hack this code worse is by using "on error resume next"