以下是全部代码
Dim y As Integer
Sub Cfile1(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, m, n, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录
idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List3.AddItem Myname
'把找到的文件显示到列表框中
List7.AddItem FileDateTime(MyPath & Myname)
List9.AddItem MyPath
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call Cfile1(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
List1.Clear
For m = 0 To (List3.ListCount - 1)
If InStr(List3.List(m), ".") > 0 Then
n = Len(Left(List3.List(m), InStr(List3.List(m), ".")))
List1.AddItem Left(List3.List(m), n - 1)
End If
Next
List5.Clear
For i = 0 To (List7.ListCount - 1)
List5.AddItem List3.List(i) & " " & List7.List(i)
Next
End Sub
Sub Cfile2(MyPath As String)
Dim Myname As String
Dim a As String
Dim B() As String
Dim dir_i() As String
Dim i, m, n, idir As Long
If Right(MyPath, 1) <> "\" Then MyPath = MyPath + "\"
Myname = Dir(MyPath, vbDirectory Or vbHidden Or vbNormal Or vbReadOnly)
Do While Myname <> ""
If Myname <> "." And Myname <> ".." Then
If (GetAttr(MyPath & Myname) And vbDirectory) = vbDirectory Then '如果找到的是目录
idir = idir + 1
ReDim Preserve dir_i(idir) As String
dir_i(idir - 1) = Myname
Else
List4.AddItem Myname
'把找到的文件显示到列表框中
List8.AddItem FileDateTime(MyPath & Myname)
List10.AddItem MyPath
End If
End If
Myname = Dir '搜索下一项
Loop
For i = 0 To idir - 1
Call Cfile2(MyPath + dir_i(i))
Next i
ReDim dir_i(0) As String
List2.Clear
For m = 0 To (List4.ListCount - 1)
If InStr(List4.List(m), ".") > 0 Then
n = Len(Left(List4.List(m), InStr(List4.List(m), ".")))
List2.AddItem Left(List4.List(m), n - 1)
End If
Next
List6.Clear
For i = 0 To (List8.ListCount - 1)
List6.AddItem List4.List(i) & " " & List8.List(i)
Next
End Sub
Sub Sentense()
List2.Clear
List4.Clear
List6.Clear
List8.Clear
List10.Clear
Cfile2 ("D:\count\")
Dim i, j, k As Integer
For i = 0 To (List4.ListCount - 1)
For j = 0 To (List3.ListCount - 1)
If List4.List(i) = List3.List(j) Then Exit For
Next
If j = List3.ListCount Then
MsgBox "新发放文件" & vbCrLf & List2.List(i) & vbCrLf & vbCrLf & "发放时间" & vbCrLf & List8.List(i) & vbCrLf & vbCrLf & "文件路径:" & vbCrLf & List10.List(i), 64, "提醒"
End If
Next
For i = 0 To (List3.ListCount - 1)
For j = 0 To (List4.ListCount - 1)
If List3.List(i) = List4.List(j) Then Exit For
Next
If j = List4.ListCount Then
MsgBox "以下文件已删除" & vbCrLf & List1.List(i), 64, "提醒"
End If
Next
For i = 0 To (List4.ListCount - 1)
For j = 0 To (List3.ListCount - 1)
If List4.List(i) = List3.List(j) Then
If List10.List(i) = List9.List(j) Then
If List8.List(i) <> List7.List(j) Then
MsgBox "以下文件有更新" & vbCrLf & List2.List(i) & vbCrLf & vbCrLf & "更新时间" & vbCrLf & List8.List(i) & vbCrLf & vbCrLf & "文件路径:" & vbCrLf & List10.List(i), 64, "提醒"
End If
End If
End If
Next
Next
List1.Clear
List3.Clear
List5.Clear
List7.Clear
List9.Clear
Cfile1 ("D:\count\")
End Sub
Private Sub Form_Load()
List1.Clear
List3.Clear
List5.Clear
List7.Clear
Cfile1 ("D:\count\")
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
y = y + 1
If y = 10 Then
y = 0
Call Sentense
End If
End Sub