在程序进行长时间过程操作时,比如导入数据时,显示消耗的时间
从零开始计时,计时所需时间,如何实现,拜托各位

解决方案 »

  1.   

    設置timer的intervaltimer.enabled=true
    '調用导入数据的過程
    '過程執行完後關閉timer
    timer.enabled=false
    '在Timer1_Timer事件中顯示時間給user
    Private Sub Timer1_Timer()
    '顯示時間的代碼
    End Sub
      

  2.   

    Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    '获取自windows启动以来经历的时间长度(毫秒)

    Public Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemTime" (lpSystemTime As SYSTEMTIME)
    Public Type SYSTEMTIME
            wYear As Integer
            wMonth As Integer
            wDayOfWeek As Integer
            wDay As Integer
            wHour As Integer
            wMinute As Integer
            wSecond As Integer
            wMilliseconds As Integer
    End Type
    简单的计算下就可以了,timeend-timebegin.
      

  3.   

    根据我的经验,最好是用 GetTickCount 而不用 Timer 对象或控件。在模块中
    Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long或在窗体中通用段
    Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long然后在过程中:
    dim tt as long    tt = GetTickCount()
        '执行你的代码
        '.....
        tt =  GetTickCount() - tt    所得的是毫秒值。
      

  4.   

    问一下,如果用gettickcount的话能不能产生一个象用Timer控件的效果啊?就是要让它在固定的时间间隔定时触发一个事件,能行吗?
      

  5.   

    虽然用Timer定时的时间不准确,但是可以定时触发总是比较有用处,可以在处理其它事件的同时完成计时,用gettickcount能作到吗?谁给介绍一下,如果能该怎么实现啊?