vb怎样让图片来回运动?

来源:百度知道 编辑:UC知道 时间:2024/09/23 06:43:52
就是图片要越出边界的时候又可以让它返回运动
我知道拉
但问题怎么判断呢?

Private Sub Timer1_Timer()
If L2(1).Left < Width Then
L2(1).Left = L2(1).Left + 1000
If L2(1).Left + L2(1).Width >= Width Then
L2(0).Visible = True
L2(0).Left = L2(0).Left + 1000
If L2(0).Left >= 0 Then
L2(1).Left = L2(0).Left
L2(0).Left = -L2(0).Width
L2(0).Visible = False
End If
End If
End If
End Sub
应该就是滚动条那样把?

如果越出左右边界,你就用left值判断,if label1.left>=me.width-label1.width 这就是越界了! 上下边界用top值判断,道理同上!!

使用Timer移动图片Left,Top坐标

当移动到边界时, 进行判断即可!