Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Ix = X
Iy = Y
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Timer()
Dim m As Long, n As Long, p As Long, q As Long
m = Image1.Left + (Image1.Left - Ix) / Sqr((Image1.Left - Ix) * (Image1.Left - Ix) + (Image1.Top - Iy) * (Image1.Top - Iy))
n = Image1.Top + (Image1.Top - Iy) / Sqr((Image1.Top - Iy) * (Image1.Top - Iy) + (Image1.Left - Ix) * (Image1.Left - Ix))
If m = Ix Or n = Iy Then
Timer1.Enabled = False
End If
Image1.Move m, n
End Sub 作者:
netice 时间: 2006-4-13 19:58
定义有问题吧
我觉得是这样(虽然没试过)
Dim m As Varient, n As Varient(加根号后数是带许多带小数的)
还有我觉得这样好
m = Image1.Left + (Image1.Left - Ix) / (image1.left-lx+image2.top)*Sqr((Image1.Left - Ix) * (Image1.Left - Ix) + (Image1.Top - Iy) * (Image1.Top - Iy))
那么移动的距离会相等。 作者:
john135246 时间: 2008-10-15 08:25
Dim Ix As Variant, Iy As Variant
Private Sub Form_Activate()
Timer1.Enabled = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Ix = X
Iy = Y
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Timer()
Dim m As Variant, n As Variant
m = Image1.Left - (Image1.Left - Ix) / Sqr((Image1.Left - Ix) * (Image1.Left - Ix) + (Image1.Top - Iy) * (Image1.Top - Iy))
n = Image1.Top - (Image1.Top - Iy) / Sqr((Image1.Top - Iy) * (Image1.Top - Iy) + (Image1.Left - Ix) * (Image1.Left - Ix))
If m = Ix And n = Iy Then
Timer1.Enabled = False
End If
Image1.Move m, n
End Sub
这次我试过了,成功了。