当前位置:  操作系统>windows

Office 2010 Module模式下使用VBA Addressof

 
    发布时间:2014-1-13  


    本文导语:  Office 2010 Module模式下使用VBA Addressof: 在VBA中Addressof不能在Class或Form中使用,只有Module模式下才能使用Addressof以面是一个计时器的例子:Form1中代码:Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long)...

  Office 2010 Module模式下使用VBA Addressof:

 在VBA中Addressof不能在ClassForm中使用,只有Module模式下才能使用Addressof以面是一个计时器的例子:

Form1中代码:


Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Sub CommandButton1_Click()
    Module1.test
End Sub
Private Sub CommandButton2_Click()
    KillTimer 0, Module1.mHandle
End Sub

Module1下代码:



Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public mHandle As Long
Public Sub test()
    mHandle = SetTimer(0, 0, 2000, AddressOf MyTimerProce)
End Sub
Public Sub MyTimerProce(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
    MsgBox "hello"
End Sub


    您可能感兴趣的文章:

  • 本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载,整理或搜集自网络.欢迎任何形式的转载,转载请注明出处.
    转载请注明:文章转载自:[169IT-IT技术资讯]
    本文标题:Office 2010 Module模式下使用VBA Addressof
相关文章推荐:


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3