AS
VBA
Elimina un file, se esiste
Routine assegnata al pulsante
Private Sub btn_Click()
Dim currPath As String
Dim myFile As String
currPath = Application.CurrentProject.Path
myFile = currPath & "/test.txt"
deleteFile myFile
End Sub
Funzioni nel modulo
Public Function fileExists(ByVal myFile As String) As Boolean
fileExists = (Dir(myFile) <> "")
End Function
Public Sub deleteFile(ByVal myFile As String)
If fileExists(myFile) Then
SetAttr myFile, vbNormal
Kill myFile
End If
End Sub