模块:
Public Type POINTAPI
    X As Long
    Y As Long
End Type类模块:
Public Function GetPoint() As POINTAPI

解决方案 »

  1.   

    将自定义类型POINTAPI 移到类模块里面,并将public 改为private。
      

  2.   

    模块中需添加API:
        Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    该API有POINTAPI结构体。
    你的类模块中Function是作为函数使用似乎不妥。
    以下是该API的用法的一段代码:
    Option Explicit
        Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
        Private Type PointAPI
            X As Long
            Y As Long
        End Type
        Dim MousePos As PointAPI
        Dim NewX As Long
        Dim NewY As LongPrivate Sub Command2_Click()
        Print "有没有办法去响应控件(commandbutton)事件?"
    End SubPrivate Sub Form_Load()
        Me.WindowState = 2
        Command2.Enabled = False
    End SubPrivate Sub Timer1_Timer()
        GetCursorPos MousePos
        NewX = MousePos.X * Screen.TwipsPerPixelX
        NewY = MousePos.Y * Screen.TwipsPerPixelY - 300
        Label1 = NewX
        Label2 = NewY
        If NewX >= Command2.Left And NewX <= Command2.Left + Command2.Width And NewY >= Command2.Top And NewY <= Command2.Height + Command2.Top Then
            Command2_Click
        Else
            Command2.Enabled = False
            Me.Cls
        End If
    End Sub