zoukankan      html  css  js  c++  java
  • VBA精彩代码分享-2

    VBA开发中经常需要提示消息框,如果不关闭程序就会暂时中断,这里分享下VBA如何实现消息框的自动关闭,总共有三种方法:

    第一种方法

    Public Declare Function MsgBoxTimeOut Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long
    Public Sub 录入对话()
     '过程,"弹出对话","对话框标题",图标类型,默认参数,N秒后自动关闭
    MsgBoxTimeOut 0, "录入完毕!!", "提示", 64, 0, 1500
    End Sub

    第二种方法

    Sub pop()
    Dim wsh As Object
    Set wsh = CreateObject("wscript.shell")
    wsh.popup "请您输入有效数字", 1, "注意", vbInformation
    'CreateObject ("wscript.shell").popup "请您输入有效数字", 1, "注意", vbInformation
    End Sub

    第三种方法

    Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nidevent As Long, ByVal uelaspe As Long, ByVal lptimerfunc As Long) As Long
    Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nidevent As Long) As Long
    Dim TID As Long
    Const sec = 3
    Sub closetest(ByVal hwnd As Long, ByVal umsg As Long, ByVal idevent As Long, ByVal systime As Long)
    Application.SendKeys "~", True
    KillTimer 0, TID
    End Sub
    Sub 三秒钟后关闭()
    TID = SetTimer(0, 0, sec * 1000, AddressOf closetest)
    MsgBox sec & "秒钟自动关闭窗口", 65, "提示"
    End Sub
  • 相关阅读:
    多按键设计的标准思路
    与,非,或门总结
    i2c中应答信号信号总结
    i2c中start和restart的区别
    poj 1631 Bridging signals
    poj 2533 Longest Ordered Subsequence
    poj 1887 Testing the CATCHER
    poj 1088 滑雪
    poj 1014 Dividing
    babel转码时generator的regeneratorRuntime
  • 原文地址:https://www.cnblogs.com/JTCLASSROOM/p/10880998.html
Copyright © 2011-2022 走看看