明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1226|回复: 3

vba提示类型不匹配,如何解决?

[复制链接]
发表于 2015-8-13 10:37:26 | 显示全部楼层 |阅读模式
运行子程序aaa,到下面红色代码处提示“类型不匹配”,请问如何解决?
Public Declare PtrSafe Function SetTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare PtrSafe Function KillTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public lTimerID As Integer

Public Sub Start_Timer()

    If lTimerID = 0 Then
        lTimerID = SetTimer(0&, 0&, 3000, AddressOf Ontime)
    Else
        Call Stop_Timer
        lTimerID = SetTimer(0&, 0&, 3000, AddressOf Ontime)
    End If

End Sub

Public Sub Stop_Timer()
    KillTimer 0&, lTimerID
End Sub

Public Sub Ontime()
    Dim R As Integer

   R = MsgBox("ok", vbOKCancel)
   If R = vbCancel And lTimerID <> 0 Then Call Stop_Timer

End Sub

Private Sub aaa()
Call Start_Timer
End Sub

点评

我猜你是在64位系统64位cad下用32位系统的代码  发表于 2015-8-13 12:06
发表于 2015-8-13 12:05:14 | 显示全部楼层
Public Declare PtrSafe Function SetTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Longptr) As Long
Public Declare PtrSafe Function KillTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public lTimerID As Integer

Public Sub Start_Timer()

    If lTimerID = 0 Then
        lTimerID = SetTimer(0&, 0&, 3000, AddressOf Ontime)
    Else
        Call Stop_Timer
        lTimerID = SetTimer(0&, 0&, 3000, AddressOf Ontime)
    End If

End Sub

Public Sub Stop_Timer()
    KillTimer 0&, lTimerID
End Sub

Public Sub Ontime()
    Dim R As Integer

   R = MsgBox("ok", vbOKCancel)
   If R = vbCancel And lTimerID <> 0 Then Call Stop_Timer

End Sub

Private Sub aaa()
Call Start_Timer
End Sub
发表于 2015-8-13 15:53:59 | 显示全部楼层
帮顶,希望楼主尽快得到解决办法!
 楼主| 发表于 2015-8-13 16:28:19 | 显示全部楼层
zzyong00 发表于 2015-8-13 12:05
Public Declare PtrSafe Function SetTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Lon ...

非常感谢
我把long改成any,也通过调试了。
再次感谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 09:42 , Processed in 0.205266 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表