新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Command1_Click()
Dim p As POINTAPI
Call GetCursorPos(p)
'(p.x, p.y)为鼠标位置
MsgBox "X=" & p.x & " Y=" & p.y
End Sub