'VB通过拖动鼠标画矩形,并且标注对角坐标
Dim Px As Single
Dim Py As Single
Dim flag As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.AutoRedraw = False
Px = X
Py = Y
flag = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flag And Button = vbLeftButton Then
Me.Refresh
Line (Px, Py)-(X, Y), , B
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flag And Button = vbLeftButton Then
Me.AutoRedraw = True
Line (Px, Py)-(X, Y), , B
flag = False
Me.CurrentX = Px
Me.CurrentY = Py
Print "(" & Px & "," & Py & ")"
Me.CurrentX = X
Me.CurrentY = Y
Print "(" & X & "," & Y & ")"
End If
End Sub
有偿答题 有意私信