如何使用VB6.0
如何使用下列代码编写一个红绿灯程序:1.“开始”按钮代码:Timergreen.Enabled=TrueTimerAotoCheck.Enabled=FalseTimer...
如何使用下列代码编写一个红绿灯程序:
1.“开始”按钮代码:
Timergreen.Enabled = True
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbGreenTime.Caption = 3
lbRedTime.Caption = 1
lbCarSpeed.Caption = 0
txtInfo.Text = "红绿灯自动控制已启动"
btnStart.Caption = "启动"
2.“停止”按钮代码:
Timergreen.Enabled = False
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbGreenTime.Caption = 0
lbRedTime.Caption = 0
lbCarSpeed.Caption = 0
txtInfo.Text = "红绿灯自动控制已停止"
btnStart.Caption = "启动"
3.“开启人民西路红灯”按钮代码:
Timergreen.Enabled = False
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbTopLight.ForeColor = &H8000&
lbBottonLight.ForeColor = &H8000&
lbLeftLight.ForeColor = &HFF&
lbRightLight.ForeColor = &HFF&
btnStart.Caption = "继续自动控制"
txtInfo.Text = "东软大道一直亮红灯"
lbGreenTime.Caption = "X"
lbRedTime.Caption = "0"
4.“开启人民西路绿灯”按钮代码:
Timergreen.Enabled = False
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbTopLight.ForeColor = &HFF&
lbBottonLight.ForeColor = &HFF&
lbLeftLight.ForeColor = &H8000&
lbRightLight.ForeColor = &H8000&
btnStart.Caption = "继续自动控制"
txtInfo.Text = "人民西路一直亮绿灯"
lbGreenTime.Caption = "0"
5.“物联网远程车流自动检测启动”按钮代码:
TimerAotoCheck.Enabled = True
Timergreen.Enabled = False
lbRedTime.Caption = "X"
6.“TimerAuto”计时器代码:
count3 = count3 + 1
lbGreenTime.Caption = 5
lbRedTime.Caption = 1
If count3 Mod 6 = 0 Then
lbTopLight.ForeColor = &H8000& '绿色
lbBottonLight.ForeColor = &H8000&
lbLeftLight.ForeColor = &HFF& ' 红色
lbRightLight.ForeColor = &HFF&
Else
lbTopLight.ForeColor = &HFF& '红色
lbBottonLight.ForeColor = &HFF&
lbLeftLight.ForeColor = &H8000& ' 绿色
lbRightLight.ForeColor = &H8000&
End If
7.“TimerAotoCheck”计时器代码:
Dim count As Integer
count = Rnd(8) * 8
lbCarSpeed.Caption = count
counttime = counttime + 1
If counttime = 4 Then
If count >= 5 Then
txtInfo.Text = "人民西路车流较大,延长绿灯时间"
TimerAuto.Enabled = True
Timergreen.Enabled = False
counttime = 0
Else
txtInfo.Text = "人民西路车流恢复正常,绿灯恢复正常"
TimerAuto.Enabled = False
Timergreen.Enabled = True
counttime = 0
End If
End If
8.“Timergreen”计时器代码:
count2 = count2 + 1
lbGreenTime.Caption = 3
lbRedTime.Caption = 1
If count2 Mod 4 = 0 Then
lbTopLight.ForeColor = &H8000& '绿色
lbBottonLight.ForeColor = &H8000&
lbLeftLight.ForeColor = &HFF& ' 红色
lbRightLight.ForeColor = &HFF&
Else
lbTopLight.ForeColor = &HFF& '红色
lbBottonLight.ForeColor = &HFF&
lbLeftLight.ForeColor = &H8000& ' 绿色
lbRightLight.ForeColor = &H8000&
End If
图片上的红绿灯会变 展开
1.“开始”按钮代码:
Timergreen.Enabled = True
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbGreenTime.Caption = 3
lbRedTime.Caption = 1
lbCarSpeed.Caption = 0
txtInfo.Text = "红绿灯自动控制已启动"
btnStart.Caption = "启动"
2.“停止”按钮代码:
Timergreen.Enabled = False
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbGreenTime.Caption = 0
lbRedTime.Caption = 0
lbCarSpeed.Caption = 0
txtInfo.Text = "红绿灯自动控制已停止"
btnStart.Caption = "启动"
3.“开启人民西路红灯”按钮代码:
Timergreen.Enabled = False
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbTopLight.ForeColor = &H8000&
lbBottonLight.ForeColor = &H8000&
lbLeftLight.ForeColor = &HFF&
lbRightLight.ForeColor = &HFF&
btnStart.Caption = "继续自动控制"
txtInfo.Text = "东软大道一直亮红灯"
lbGreenTime.Caption = "X"
lbRedTime.Caption = "0"
4.“开启人民西路绿灯”按钮代码:
Timergreen.Enabled = False
TimerAotoCheck.Enabled = False
TimerAuto.Enabled = False
lbTopLight.ForeColor = &HFF&
lbBottonLight.ForeColor = &HFF&
lbLeftLight.ForeColor = &H8000&
lbRightLight.ForeColor = &H8000&
btnStart.Caption = "继续自动控制"
txtInfo.Text = "人民西路一直亮绿灯"
lbGreenTime.Caption = "0"
5.“物联网远程车流自动检测启动”按钮代码:
TimerAotoCheck.Enabled = True
Timergreen.Enabled = False
lbRedTime.Caption = "X"
6.“TimerAuto”计时器代码:
count3 = count3 + 1
lbGreenTime.Caption = 5
lbRedTime.Caption = 1
If count3 Mod 6 = 0 Then
lbTopLight.ForeColor = &H8000& '绿色
lbBottonLight.ForeColor = &H8000&
lbLeftLight.ForeColor = &HFF& ' 红色
lbRightLight.ForeColor = &HFF&
Else
lbTopLight.ForeColor = &HFF& '红色
lbBottonLight.ForeColor = &HFF&
lbLeftLight.ForeColor = &H8000& ' 绿色
lbRightLight.ForeColor = &H8000&
End If
7.“TimerAotoCheck”计时器代码:
Dim count As Integer
count = Rnd(8) * 8
lbCarSpeed.Caption = count
counttime = counttime + 1
If counttime = 4 Then
If count >= 5 Then
txtInfo.Text = "人民西路车流较大,延长绿灯时间"
TimerAuto.Enabled = True
Timergreen.Enabled = False
counttime = 0
Else
txtInfo.Text = "人民西路车流恢复正常,绿灯恢复正常"
TimerAuto.Enabled = False
Timergreen.Enabled = True
counttime = 0
End If
End If
8.“Timergreen”计时器代码:
count2 = count2 + 1
lbGreenTime.Caption = 3
lbRedTime.Caption = 1
If count2 Mod 4 = 0 Then
lbTopLight.ForeColor = &H8000& '绿色
lbBottonLight.ForeColor = &H8000&
lbLeftLight.ForeColor = &HFF& ' 红色
lbRightLight.ForeColor = &HFF&
Else
lbTopLight.ForeColor = &HFF& '红色
lbBottonLight.ForeColor = &HFF&
lbLeftLight.ForeColor = &H8000& ' 绿色
lbRightLight.ForeColor = &H8000&
End If
图片上的红绿灯会变 展开
2个回答
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
FileCopy 语句 复制一q个v文5件。语法 FileCopy source, destination FileCopy 语句的语法含有以7下s这些命名参数: 部分5 描述 source 必要参数。字符串表达式,用来表示6要被复制的文5件名。source 可以6包含目录或文3件夹、以8及t驱动器。 destination 必要参数。字符串表达式,用来指定要复制的目地文5件名。destination 可以1包含目录或文8件夹、以2及k驱动器。 说明如果想要对一i个a已d打开r的文6件使用 FileCopy 语句,则会产生错误。 示6例本示7例使用 FileCopy 语句来复制文4件。示4例中0假设 SRCFILE 为0含有数据的文7件。 Dim SourceFile, DestinationFile SourceFile = "SRCFILE" ' 指定源文8件名。 DestinationFile = "DESTFILE" ' 指定目的文3件名。 FileCopy SourceFile, DestinationFile ' 将源文0件的内1容复制到目的文2件中7。 FileCopy 可以4实现简单的文2件复制,更复杂的复制参照FileSystemObject对象 Set objFso = CreateObject("Scripting。FileSystemObject")
nゥ△ㄅě攀毵kug取dnゥ△ㄅě攀毵enゥ△ㄅě攀毵g取a学
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询