Private Sub Timer1_Timer()
Static num As Integer
If num = 0 Then
'红
End If
If num = 85 Then
'绿
End If
If num = 85 + 25 Then
'黄
End If
num = num + 1
num = num Mod (85 + 25 + 5)
End Sub
Static num As Integer
If num = 0 Then
'红
End If
If num = 85 Then
'绿
End If
If num = 85 + 25 Then
'黄
End If
num = num + 1
num = num Mod (85 + 25 + 5)
End Sub
解决方案 »
- 几个.net的函数在VB中如何实现
- 在listview 控件中对多个字段进行编辑更改吗?十万火急!!!
- 一个简单得sql语句说from子句语法有问题,是什么原因?————急死我了!!!
- 拒绝回答任何技术问题,谁也不欠谁,那些分连冥币都不如。
- 关于VB控制EXCEL
- VB,access菜鸟问题
- 高手请进,求助
- 在安装程序时的问题,急!!
- 小问题(送分):求控件toolbar和imagelist的用法、属性讲解、范例!
- 报错 “ScaleHeight”不是“System.Windows.Forms.PictureBox”的成员。
- 如何设置提醒功能?(急用!)
- 请问要实现在空表上建立数据时,如何做到text1.text能显示“1000”,即Number的“标识种子”值!
timer.Interval = 85
timer.Enabled = TRUETimer事件里写
sub Timer_Timer()
if timer.Interval = 85 then
redoff()
greenon()
timer.Interval = 25
elseif timer.Interval = 25 then
greenoff()
yellowon()
timer.Interval = 5
elseif timer.Interval = 5 then
yellowoff()
redon()
timer.Interval = 85
end if
end sub
只是举例,自己发挥了
单位是 0.001秒 !!!!但您也不能
timer.Interval = 85 *1000
因为 timer.Interval 是整型的,85000超出范围.
必须进行计数。
object 对象表达式,其值是“应用于”列表中的一个对象。
milliseconds 数值表达式,指定毫秒数,“设置值”中有详细说明,。
设置值milliseconds 的设置值为:设置值 描述
0 (缺省值)使 Timer 控件无效。
1 to 65,535 设置的时间间隔(以毫秒计),在 Timer 控件 Enabled 属性设置为 True 时开始有效,例如,10,000 毫秒等于 10 秒。最大值为 65,535 毫秒,等于 1 分钟多一些。
说明可以在设计时或在运行时设置 Timer 控件的 Interval 属性。使用 Interval 属性时,请记住:?Timer 控件的 Enabled 属性决定该控件是否对时间的推移做响应。将Enabled 设置为 False 会关闭 Timer 控件,设置为 True 则打开它。当 Timer 控件置为有效时,倒计时总是从其 Interval 属性的设置值开始。
?创建 Timer 事件程序用以告诉 Visual Basic 在每次 Interval 到时该做什么。
以下代码供参考:
Public mytime As Long
Private Sub Form_Load()
mytime = 0
End SubPrivate Sub Timer1_Timer()
With Shape1
If mytime <= 85 Then .BorderColor = vbRed: .FillColor = vbRed: Label1.Caption = 85 - mytime
If mytime > 85 And mytime <= 110 Then .BorderColor = vbGreen: .FillColor = vbGreen: Label1.Caption = 110 - mytime
If mytime > 110 And mytime <= 115 Then .BorderColor = vbYellow: .FillColor = vbYellow: Label1.Caption = 115 - mytime
mytime = mytime + 1
If mytime >= 116 Then mytime = 0
Print Time
End With
End Sub