vb Kill语句的问题

来源:百度知道 编辑:UC知道 时间:2024/09/28 12:12:35
请问VB中Kill语句要怎么样才能删除C:\widd\下除了txt以外的所有文件呢?

Option Explicit
Private Sub Command1_Click()
Dim a As String, s As String, str() As String, i As Integer
a = Dir("c:\widd\*.*")
s = a & vbCrLf
Do While a <> ""
a = Dir
s = s & a & vbCrLf
Loop
s = Left(s, Len(s) - 1)
str() = Split(s, vbCrLf)
For i = 0 To UBound(str) - 1
If Not Right(str(i), 3) = "txt" Then Kill "c:\widd\" & str(i)
Next
End Sub

Private Sub Command1_Click()
On Error Resume Next
Dim b() As String, n As Integer, a As String
sPath = "c:\widd\"

a = Dir(sPath)
b = Split(a, ".")

If LCase(b(UBound(b))) <> "txt" Then
Kill Replace(sPath & a, "\\", "\")
End If

Do While a <> ""
a = Dir
b = Split(a, ".")
If LCase(b(UBound(b))) <> "txt" Then
Kill Re