VB十字路口交通灯控制
展开全部
'窗体上用图形控件画一个圆,并将其Index属性设置为0,再画一个时钟控件,复制代码过去即可。
Private Sub Form_Load()
Me.AutoRedraw = True
Timer1.Enabled = True
Timer1.Interval = 2000
Shape1(0).Visible = False
For i = 1 To 3
Load Shape1(i)
If i = 1 Then Shape1(i).FillColor = vbYellow
If i = 2 Then Shape1(i).FillColor = vbGreen
If i = 3 Then Shape1(i).FillColor = vbYellow
Shape1(i).Visible = False
Next
End Sub
Private Sub Timer1_Timer()
Static t As Long
i = t Mod 4
If i = 0 Then
Shape1(0).Visible = True
Shape1(1).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = False
ElseIf i = 1 Then
Shape1(0).Visible = False
Shape1(1).Visible = True
Shape1(2).Visible = False
Shape1(3).Visible = False
ElseIf i = 2 Then
Shape1(0).Visible = False
Shape1(1).Visible = False
Shape1(2).Visible = True
Shape1(3).Visible = False
ElseIf i = 3 Then
Shape1(0).Visible = False
Shape1(1).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = True
End If
t = t + 1
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
Timer1.Enabled = True
Timer1.Interval = 2000
Shape1(0).Visible = False
For i = 1 To 3
Load Shape1(i)
If i = 1 Then Shape1(i).FillColor = vbYellow
If i = 2 Then Shape1(i).FillColor = vbGreen
If i = 3 Then Shape1(i).FillColor = vbYellow
Shape1(i).Visible = False
Next
End Sub
Private Sub Timer1_Timer()
Static t As Long
i = t Mod 4
If i = 0 Then
Shape1(0).Visible = True
Shape1(1).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = False
ElseIf i = 1 Then
Shape1(0).Visible = False
Shape1(1).Visible = True
Shape1(2).Visible = False
Shape1(3).Visible = False
ElseIf i = 2 Then
Shape1(0).Visible = False
Shape1(1).Visible = False
Shape1(2).Visible = True
Shape1(3).Visible = False
ElseIf i = 3 Then
Shape1(0).Visible = False
Shape1(1).Visible = False
Shape1(2).Visible = False
Shape1(3).Visible = True
End If
t = t + 1
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
广州市双宝电子科技有限公司_
2024-11-19 广告
2024-11-19 广告
广州市双宝电子科技股份有限公司,数10年来贯彻人、车、物三位一体的综合安全管理理念。帮助企业进行厂区人车智能管理、提高厂区工作效率。我们本身就有一条专注、专业的售后团队,持着「积极创新、勇于开拓、满足顾客、团队合作」的理念,力争打造为安全防...
点击进入详情页
本回答由广州市双宝电子科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |