我正在尝试将picturebox1编码移动,因为我点击button1它确实有效,但问题是picturebox1不停地移动,即使我已经设置它停止的条件但是如果我放PictureBox1.Left + 1
它将停止我想要的确切点但我希望它更快,所以我需要它PictureBox1.Left + 5
这是我写的代码:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
PictureBox1.Location = New Point(PictureBox1.Left + 5, PictureBox1.Top + 0)
If PictureBox1.Left = 343 Then
Timer1.Stop()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Start()
End Sub
Timer1间隔为1 Enable = false
答案 0 :(得分:0)
343不是5的倍数,因此该值永远不会相等。您应该测试.left >343
为了让动画更流畅我建议增加1并减少定时器间隔时间