VB错误:必选参数
代码:Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Timer1_Timer()
GetCursorPos p
List2.AddItem = Time() + Chr(32) + p.x + Chr(32) + p.y
End Sub
'参考如下
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Timer1_Timer()
Dim p As POINTAPI
GetCursorPos p
'List2.AddItem 后不能用 "=";不同类型数据不能用 "+",而应使用 "&"
'List2.AddItem Time() & Chr(9) & "x =" & p.x & Chr(9) & "y=" & p.y
'为了便于演示,这里将结果输出到 Text1
Text1.Text = Time() & Chr(9) & "x =" & p.x & Chr(9) & "y=" & p.y
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
运行过程录屏