VB用IF else方式 根据时间显示文字 最好两种方法的一种也行

来源:百度知道 编辑:UC知道 时间:2024/06/01 05:48:14
如果用Timer控件该怎么弄比如3秒时显示一句话6秒显示一句话这样的

第一种
Private Sub Form_Load()
Timer1.Interval = 3000
End Sub

Private Sub Timer1_Timer()
If Timer1.Interval = 3000 Then
Print "3秒"
Timer1.Interval = 6000
ElseIf Timer1.Interval = 6000 Then
Print "6秒"
Timer1.Interval = 3000
End If
End Sub
第二种
Private Sub Form_Load()
Timer1.Interval = 3000
End Sub

Private Sub Timer1_Timer()
Select Case Timer1.Interval
Case 3000
Print "3秒"
Timer1.Interval = 6000
Case 6000
Print "6秒"
Timer1.Interval = 3000
End Select
End Sub

dim t
t=hour(now())
if t>0 and t<6 then
print "现在是黎明前"
elseif t>=6 and t<12 then
print "现在时早上"
elseif t>=12 and t<18 then
print "现在是下午"
elseif t>=18 and t<24 then
print "现在是晚上"
end if

第一种 IF ...THEN... ELSE...

t = Left(Ti