主题:如何返回坐标值
Dim x1, y1, x2, y2 As Single
Dim d1, d2 As Single
Dim uo As Boolean
Private Sub Command1_Click()
MsgBox d1
MsgBox d2
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = X: y1 = Y
x2 = X: y2 = Y
uo = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Cls
If uo = True Then
Line (x1, y1)-(x2, y2), vbBlue, B
x2 = X: y2 = Y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
uo = False
d1 = x2: d2 = y2
MsgBox d1
MsgBox d2
End Sub
新建form1,添加command1,绘制矩形时,我想在鼠标松开时,使d1,d2记住结束时的鼠标坐标值,在单击command1时输出鼠标结束时的d1,d2值,但这是空值,怎样能使其值返回,请高手指点下。
Dim d1, d2 As Single
Dim uo As Boolean
Private Sub Command1_Click()
MsgBox d1
MsgBox d2
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = X: y1 = Y
x2 = X: y2 = Y
uo = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Cls
If uo = True Then
Line (x1, y1)-(x2, y2), vbBlue, B
x2 = X: y2 = Y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
uo = False
d1 = x2: d2 = y2
MsgBox d1
MsgBox d2
End Sub
新建form1,添加command1,绘制矩形时,我想在鼠标松开时,使d1,d2记住结束时的鼠标坐标值,在单击command1时输出鼠标结束时的d1,d2值,但这是空值,怎样能使其值返回,请高手指点下。