Login
网站首页 > 文章中心 > VB6

VB6 分钟级延迟函数分享(窗体不卡顿)

作者:小编 更新时间:2024-03-08 21:21:50 浏览量:177人看过

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub DelayMinutes(ByVal minutes As Integer)

    Dim endTime As Date

    endTime = DateAdd("n", minutes, Now)


    Do

        DoEvents ' 允许系统处理其他事件

        Sleep 100 ' 暂停100毫秒

    Loop While Now < endTime


    MsgBox "延迟已完成!"

End Sub


Private Sub Form_Load()

    DelayMinutes 3

End Sub

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

下面是 带剩余秒数提示的:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub DelayMinutes(ByVal minutes As Integer)

    Dim endTime As Date

    endTime = DateAdd("n", minutes, Now)


    Do

        DoEvents ' 允许系统处理其他事件

        Sleep 100 ' 暂停100毫秒

    Loop While Now < endTime


    MsgBox "延迟已完成!"

End Sub


Private Sub Form_Load()

    DelayMinutes 3

End Sub


版权声明:倡导尊重与保护知识产权,本站有部分资源、图片来源于网络,如有侵权,请联系我们修改或者删除处理。
转载请说明来源于"土嘎嘎" 本文地址:http://www.tugaga.com/jishu/vb/1866.html
<<上一篇 2024-01-21
下一篇 >> 2024-04-15

编辑推荐

热门文章