vb实现高精度计时

sangmj1818

sangmj1818

2016-02-19 14:55

下面是个vb实现高精度计时教程,撑握了其技术要点,学起来就简单多了。赶紧跟着图老师小编一起来看看吧!

  

'在Project中加入一个Module,然后在其中加入以下代码:Option ExplicitType LARGE_INTEGER  lowpart As Long  highpart As LongEnd TypePublic Declare Function QueryPerformanceCounter Lib "kernel32" _    (lpPerformanceCount As LARGE_INTEGER) As LongPublic Declare Function QueryPerformanceFrequency Lib "kernel32" _    (lpFrequency As LARGE_INTEGER) As LongPublic 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 LongPublic Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As LongPublic Declare Function GetTickCount Lib "kernel32" () As LongPublic lMSFreq As LongPublic TimerCount As SinglePublic lmmCount As SinglePublic lTimeID As LongPublic actTime1 As LongPublic actTime2 As LongPublic iCountStart As SingleDim 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 IfEnd SubSub 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 WithEnd Sub

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)
展开更多 50%)
分享

猜你喜欢

vb实现高精度计时

编程语言 网络编程
vb实现高精度计时

DELPHI高精度计时方法

编程语言 网络编程
DELPHI高精度计时方法

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

用VB计算累计时间值

编程语言 网络编程
用VB计算累计时间值

vb实现隐藏Mouse

编程语言 网络编程
vb实现隐藏Mouse

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

利用VB实现浮动按钮

编程语言 网络编程
利用VB实现浮动按钮

VB实现按钮浮动效果

编程语言 网络编程
VB实现按钮浮动效果

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

QQ文件的传输速度太慢怎么办

QQ文件的传输速度太慢怎么办

关于解决Java编程语言线程问题的建议

关于解决Java编程语言线程问题的建议
下拉加载更多内容 ↓