'窗体加一个timer1
Dim x As Boolean
Private Sub Form_Load()
Timer1.Interval = 50
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer() '
If x Then
Shape1.Left = Shape1.Left - 100
Else
Shape1.Left = Shape1.Left + 100
End If
If Shape1.Left >= Me.ScaleWidth - Shape1.Width Then
x = True
ElseIf Shape1.Left <= 0 Then
x = False
End If
End Sub
搜一下:VB要求在窗体上一小球(shape1)从左到右移动,到右边界后反向移动,如此往复