能有高手帮忙看下程序

来源:百度知道 编辑:UC知道 时间:2024/05/31 08:54:47
一加速或者加速就在拐角出停止... 郁闷~
就是让一个图片按矩形匀速运行,然后在文本框输入一个值让它减速或者加速,问题是如果让它匀速就可以正常拐弯,一加速或者减速吼就在拐弯处停止了,不知道怎么回事嘞,高手帮忙看下程序呀~ 谢谢了
Dim s As String
Dim v0 As String
Dim t As String
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Command3_Click()
Timer2.Enabled = True
End Sub

Private Sub Form_Load()
v0 = 100
t = 1

End Sub

Private Sub Timer1_Timer()
s = v0 * t
If Image1.Left = 500 And Image1.Top = 500 Then
Image1.Move Image1.Left + s
ElseIf Image1.Left > 500 And Image1.Left < 6500 And Image1.Top = 500 Then
Image1.Move Image1.Left + s
ElseIf Image1.Left = 6500 And Image1.Top = 500 Then
Image1.Move Image1.Left, Image1.Top + s
ElseIf Image1.Left = 6500 And Image1.Top > 500 And Image1.Top < 5600 Then
Image1.Move Image1.Left, Image1.Top + s
ElseIf Ima

你的程序太乱,我给你重写了一下,控件还是你的那些控件

Const mLeft = 50
Const mTop = 50
Const mDown = 5000
Const mRight = 5000
Dim CurrentDirect As Integer '定义当前方向
Dim cV As Single '当前速度
Dim tV As Single '目标速度

Private Sub Command1_Click()
cV = 100
CurrentDirect = 1
Form1.ScaleMode = 0
Form1.Scale (0, 0)-(5500, 6000)
Image1.Move 50, 50
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Command3_Click()
tV = Val(Text1.Text)
End Sub

Private Sub Timer1_Timer()
'定义四方向的边界坐标
'1向右,2向下,3 向左,4向上
Dim cL As Long, cT As Long
cL = Image1.Left
cT = Image1.Top
If tV > 0 Then
If cV > tV Then
cV = cV - 1
ElseIf cV < tV Then
cV = cV + 1
Else