2个回答
展开全部
在窗体中放入一个Shape1和一个Timer1,编程如下:
Private Sub Form_Load()
Shape1.FillStyle = 0
Shape1.FillColor = vbRed
Shape1.Shape = 3
Shape1.Move 0, 0, 450, 450
Timer1.Interval = 30
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static mx As Integer, my As Integer
Dim cx As Single, cy As Single
cx = Shape1.Left
cy = Shape1.Top
If (cx = 0 And cy <= 0) Or (mx = 0 And my = 0) Then
mx = 30
my = 0
cx = 0
cy = 0
ElseIf cx >= Me.ScaleWidth - Shape1.Width And cy = 0 Then
mx = 0
my = 30
cx = Me.ScaleWidth - Shape1.Width
cy = 0
ElseIf cx = Me.ScaleWidth - Shape1.Width And cy >= Me.ScaleHeight - Shape1.Height Then
mx = -30
my = 0
cx = Me.ScaleWidth - Shape1.Width
cy = Me.ScaleHeight - Shape1.Height
ElseIf cx <= 0 And cy = Me.ScaleHeight - Shape1.Height Then
mx = 0
my = -30
cx = 0
cy = Me.ScaleHeight - Shape1.Height
End If
Shape1.Move cx + mx, cy + my
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个以前做过。
什么时候要?
什么时候要?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询