VB语言

本类阅读TOP10

·Visual Basic 安装程序的制作!!
·VB中使用EXCEL输出
·一个简单的MP3播放器
·VB程序实现WindowsXP效果的界面!!
·VB打造超酷个性化菜单(六)
·透明位图
·平铺与拉伸MDI窗口的背景图 ~!~
·对《VB程序实现WindowsXP效果的界面》一文的补遗
·从Windows资源管理器中拖动文件
·VB打造超酷个性化菜单(一)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
高进度计时,精确到0.001秒,且不受任何干扰!

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

'在Project中加入一个Module,然后在其中加入以下代码:
Option Explicit

Type LARGE_INTEGER
    lowpart As Long
    highpart As Long
End Type

Public Declare Function QueryPerformanceCounter Lib "kernel32" _
        (lpPerformanceCount As LARGE_INTEGER) As Long
Public Declare Function QueryPerformanceFrequency Lib "kernel32" _
        (lpFrequency As LARGE_INTEGER) As Long
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal _
        uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, _
        ByVal uFlags As Long) As Long
Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
Public Declare Function GetTickCount Lib "kernel32" () As Long

Public lMSFreq As Long
Public TimerCount As Single
Public lmmCount As Single
Public lTimeID As Long
Public actTime1 As Long
Public actTime2 As Long
Public iCountStart As Single

Dim iCount As Single

'注释: timeSetEvent的回调函数
Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, _
    ByVal dw1 As Long, ByVal dw2 As Long)
   
    Form1.Text2.Text = Format$(lmmCount, "00.00")
    lmmCount = lmmCount - 0.01
    If lmmCount <= 0 Then
        iCountStart = 60
        lmmCount = 60
        TimerCount = 60
        EndCount
    End If
End Sub
Sub EndCount()
    iCount = iCountStart
    iCountStart = 0
    timeKillEvent lTimeID
    actTime2 = GetTickCount - actTime1
    With Form1
        .Command1.Enabled = True
        .Command2.Enabled = False
        .Timer1.Enabled = False
       
        .Text1 = "计数器记时" + Format$((60 - iCount), "00.00") + "  " _
                + "实际经过时间" + Format$((actTime2 / 1000), "00.00")
        .Text2 = "计数器记时" + Format$((60 - lmmCount), "00.00") + "  " _
                + "实际经过时间" + Format$((actTime2 / 1000), "00.00")
        .Text3 = "计数器记时" + Format$((60 - TimerCount), "00.00") + "  " _
                + "实际经过时间" + Format$((actTime2 / 1000), "00.00")
    End With
End Sub




相关文章

相关软件