下面这个希望可以帮到你~交通灯
北碚ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!
实例说明在本实例中,我们将制作一个具有交通灯效果的应用程序。程序运行后,交通灯不断地变化,可以通过按钮运行或停止程序。程序运行结果如图88-1所示。技术要点l 不断变换图片l 不断更改时间间隔 type="text/javascript" type="text/javascript" src=" "
实现过程■ 新建项目打开Visual Studio.NET,选择"新建项目",在项目类型窗口中选择"Visual Basic项目",在模板窗口中选择"Windows应用程序",在名称域中输入"Traffic",然后选择保存路径。单击"确认"。■ 添加控件向当前窗体添加一个Timer控件,用于控制交通灯变换的时间;三个Picture控件,分别装入相应的图片;一个Button按钮,用于控制交通灯。属性保持默认值。■ 添加代码Dim vv As BooleanDim updirec As BooleanPrivate Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Clickvv = Timer1.Enabledvv = Not vvTimer1.Enabled = vvIf vv ThenCommand1.Text = "开 始"ElseCommand1.Text = "停 止"End IfEnd SubPrivate Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.TickStatic i As ShortSelect Case iCase 0Timer1.Interval = 3000picicon0.Visible = Truepicicon1.Visible = Falsepicicon2.Visible = Falsei = i + 1updirec = FalseCase 1Timer1.Interval = 1000picicon0.Visible = Falsepicicon1.Visible = Truepicicon2.Visible = False'Me.Icon = picicon(i).ImageIf updirec Theni = i - 1Elsei = i + 1End IfCase 2Timer1.Interval = 3000picicon0.Visible = Falsepicicon1.Visible = Falsepicicon2.Visible = Truei = i - 1updirec = TrueEnd SelectEnd Sub■ 运行程序单击菜单"调试|启动"或单击 图标运行程序。
SCON = 0x50; //REN=1允许串行接受状态,串口工作模式1 TMOD|= 0x20; 试下这个程序,PC发什么,它就回送什么,收到数据,点亮P2.0的LED。
给你思路把:当汽车运动时,他的left和top和right(left+width)和bottom(top+height)碰到红绿灯的范围,就停止汽车运动的那个计时器,并将另一个计时器的时间设为延时秒数并开启,里面的代码是打开骑车运动的计时器。
1、使用label(标签)来模拟灯,只要修改label背景就可以实现跑马灯效果。
2、工具vb6
3、示例:
Private WithEvents NewTimer As Timer
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 10
Set NewLabel = Controls.Add("vb.label", "label" i, Me)
NewLabel.Move i * 200, 100, 100, 100
NewLabel.BackColor = vbWhite
NewLabel.Visible = True
Next
Set NewTimer = Controls.Add("vb.timer", "Timer1", Me)
NewTimer.Interval = 200
NewTimer.Enabled = True
End Sub
Private Sub NewTimer_Timer()
Static i As Integer
i = i + 1
Me("label" i).BackColor = vbRed
If i = 1 Then
If i = 1 Then i = 11
Me("label" i - 1).BackColor = vbWhite
If i = 11 Then i = 1
End If
If i = 10 Then i = 0
End Sub
4、注意:复制以上代码到代码窗体,不要加任何控件,直接运行即可。