Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long   '用来获取鼠标位置
Public Type POINTAPI
    x As Long
    y As Long
End Type
GetCursorPos Pnt
X1 = Pnt.x   '返回当前坐标X
Y1 = Pnt.y   '返回当前坐标Y

解决方案 »

  1.   

    '------module
    Option Explicit
    Type POINTAPI
        X As Long
        Y As Long
    End Type
    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long 
    '--------form
    Option Explicit
    Dim z As POINTAPIPrivate Sub Timer1_Timer()
        GetCursorPos z
        Label1 = "x: " & z.X
        Label2 = "y: " & z.Y
    End Sub
      

  2.   

    Private Type POINTAPI
        X As Long
        Y As Long
    End TypePrivate Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
      

  3.   

    在模快中定义Public Type POINTAPI
       X As Long
       Y As Long
    End Type
    Public pt As POINTAPI
    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long'=================
    Private Sub Command1_Click()
                   Call GetCursorPos(pt)
                   Debug.Print pt.X
                   Debug.Print pt.Y
    End Sub
      

  4.   

    haha ,上面都说了,我就不说了
      

  5.   

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    Dim p As POINTAPI
    Dim x1 As Long
    Dim y1 As LongPrivate Sub Form_Load()
    Me.WindowState = 2
    End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)GetCursorPos p
    x1 = p.x
    y1 = p.y
    MsgBox "(" & x1 & "," & y1 & ")"End Sub