求用vb编一段程序求坐标变化量

来源:百度知道 编辑:UC知道 时间:2024/06/08 03:36:01
就是在picture1上先点一点,再点一点,在text框里可以显示出Δx,Δy,谁可以帮帮我?

Dim k%, m%, n%
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
k = k + 1
Picture1.DrawWidth = 5
Picture1.PSet (X, Y)

End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

If k > 2 Or k = 2 Then
Text1 = X - m: Text2 = Y - n'-------①
k = 0
Picture1.Cls
End If
m = X: n = Y

End Sub

需要建立两个文本框和一个Picture控件,m、n、k都要在“通用”里定义。如果Δx,Δy需要绝对值的话,你就在①那句加个绝对值函数处理下就行了。

请楼主参考~~