Results 1 to 4 of 4

Thread: Kill File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Cool Kill File

    Hi everyone in vb land!

    Hey so I have this code the erases files on a floppy. The problem is when I use this kill file code and the floppy is empty I get an error message “File not found”. Does anyone know how to trap this error or see if the floppy is empty first?

    Code: Private Sub Command1_Click()
    Kill “A:\*.t”
    End Sub
    Thanks for any help

    reston

  2. #2
    Lively Member
    Join Date
    Feb 2003
    Posts
    117
    Maybe you could use a filelist box and navigate to a:
    VB Code:
    1. On Error GoTo a
    2.     file1.Path = "A:\"
    3.     For i = 0 To File1.ListCount - 1
    4.         If Right(File1.List(i), 2) = ".t" Then
    5.             'stuff
    6.         End If
    7.     Next
    8.  
    9. a:
    10.     If Err.Number = 68 Then
    11.         MsgBox "No Disk"
    12.     End If

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Like:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  
    5.     If Dir$("A:\*.txt", vbNormal) <> "" Then
    6.         'File exists
    7.         Kill "A:\*.txt"
    8.     End If
    9.  
    10. End Sub




    Edit
    Note: If using a wildcard "*" like that, the first file returned will be deleted.






    Bruce.
    Last edited by Bruce Fox; Apr 26th, 2004 at 10:45 PM.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Resolved kill file

    Thanks you for the help

    reston

    This is what i'm using

    Private Sub Command1_Click()
    On Error GoTo a:
    ace = 69
    If Dir$("A:\*.txt", vbNormal) <> "" Then
    'File exists
    Kill "A:\*.txt"
    End If

    a:
    If Err.Number = 52 Then
    MsgBox "Please insert disc!", vbOKOnly, "Floppy Disc Error"
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width