首先定义变量在Timer控件里编写程序如下
Dim Xx as integer
Dim Ii as integer
IF shape1.left > 0 or shape1.left + shape1.width < Me.width Then
IF shape1.top >0 or shape1.top + shape1.Hight < Me.Hight Then
Xx = -Xx
Ii =-Ii
End IF
End IF
shape1.left = shape1.left + Xx * 111
shape1.top = shape1.top + Ii * 111
在窗体的load中加上
Xx = 1: Ii = i
Timer1.Intevnl = 30
就这么简单