
1个回答
展开全部
新建工程,1个timer1,1个shape,代码如下:
Dim i%
Private Sub Form_Load()
With Shape1
.Shape = 3
.BackColor = vbRed
.BackStyle = 1
.Height = 500
.Width = 500
End With
i = 0
Timer1.Enabled = True
Timer1.Interval = 30
End Sub
Private Sub Timer1_Timer()
If i = 0 Then
Shape1.Left = Shape1.Left + 20
If Shape1.Left = Me.ScaleWidth - Shape1.Width Then i = 1
ElseIf i = 1 Then
Shape1.Left = Shape1.Left - 20
If Shape1.Left = 0 Then i = 0
End If
End Sub
Dim i%
Private Sub Form_Load()
With Shape1
.Shape = 3
.BackColor = vbRed
.BackStyle = 1
.Height = 500
.Width = 500
End With
i = 0
Timer1.Enabled = True
Timer1.Interval = 30
End Sub
Private Sub Timer1_Timer()
If i = 0 Then
Shape1.Left = Shape1.Left + 20
If Shape1.Left = Me.ScaleWidth - Shape1.Width Then i = 1
ElseIf i = 1 Then
Shape1.Left = Shape1.Left - 20
If Shape1.Left = 0 Then i = 0
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询