会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
技术文档 > VB文档 > 系统控制
高进度计时,精确到0.001秒,且不受任何干扰
发表日期:2003-07-02 00:00:00作者:s 出处:  

'在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

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00382