比如我的程序扫描磁盘中的所有文件,怎么才能用进度条跟踪记录扫描进度呢?关键是不知道扫描的总时间是多少啊

解决方案 »

  1.   

    Sub ShowFolderList(ByVal mvDrive As String, ByVal mvPath As String)    If Right(mvPath, 10) <> "|NONE|HERE" Then
        
            Dim fs, f, f1, fc, s
            Dim mvFound As Boolean
            
            mvFound = False
            Set fs = CreateObject("Scripting.FileSystemObject")
            If mvPath = "main" Then
                mvPath = ""
            End If
            Set f = fs.GetFolder(mvDrive & mvPath)
            Set fc = f.SubFolders
            
            For Each f1 In fc
            
                mvFound = True
                If mvPath = "" Then
                    trvDriveView.Nodes.Add "main", tvwChild, f1.Name, f1.Name & " (" & Format((f1.Size / 1024) / 1024, "#0.00") & " MB)"
                Else
                    trvDriveView.Nodes.Add mvPath, tvwChild, mvPath & "\" & f1.Name, f1.Name & " (" & Format((f1.Size / 1024) / 1024, "#0.00") & " MB)"
                End If
                trvDriveView.Refresh
            
            Next
                
            If mvFound = False Then
            
                If mvPath = "" Then
                    trvDriveView.Nodes.Add "main", tvwChild, "|NONE|HERE", "当前路径没有文件夹!"
                Else
                    trvDriveView.Nodes.Add mvPath, tvwChild, mvPath & "\|NONE|HERE", "当前路径没有文件夹!"
                End If
                
            End If
        End If
    End Sub
      

  2.   

    文件个数:
    dim fso
    set fso=createobject("Scripting.FilesystemObject")
    debug.print fso.getfolder("c:\temp").files.count
    set fso=nothing
      

  3.   

    好啊!谢谢大家的支持,可以结帖给分了,特别谢谢trade2004和hot1kang1(小许)