让一个红色圆每隔一秒下移100缇,当遇到窗体底部改成向上移,遇到窗体顶部改成向下移直到按按钮后停止
2个回答
展开全部
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
Command1.Caption = IIf(Timer1.Enabled, "停止", "继续")
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillColor = vbRed
Shape1.FillStyle = 0
Shape1.BorderColor = vbRed
Timer1.Interval = 1000
Timer1.Enabled = True
Command1.Caption = "停止"
End Sub
Private Sub Timer1_Timer()
Static goUp As Boolean
Shape1.Top = Shape1.Top + IIf(goUp, -100, 100)
If goUp = True Then
If Shape1.Top < 0 Then goUp = False
Else
If Shape1.Top > Form1.ScaleHeight - Shape1.Height Then goUp = True
End If
End Sub
Timer1.Enabled = Not Timer1.Enabled
Command1.Caption = IIf(Timer1.Enabled, "停止", "继续")
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillColor = vbRed
Shape1.FillStyle = 0
Shape1.BorderColor = vbRed
Timer1.Interval = 1000
Timer1.Enabled = True
Command1.Caption = "停止"
End Sub
Private Sub Timer1_Timer()
Static goUp As Boolean
Shape1.Top = Shape1.Top + IIf(goUp, -100, 100)
If goUp = True Then
If Shape1.Top < 0 Then goUp = False
Else
If Shape1.Top > Form1.ScaleHeight - Shape1.Height Then goUp = True
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询