熟醉蟹的制作方法:关于VB 的timer 怎么用

来源:百度文库 编辑:高校问答 时间:2024/04/29 11:19:59
我刚刚学VB,尽量详细点
比如我想让Command1.Caption每1秒变有下,
time=1的时候,Command1.Caption="你好"
time=2的时候,Command1.Caption="hello"
time=3的时候, Command1.Caption="喂"
.......

请将Timer1属性INTERVAL设为1000
Option Explicit
Dim n As Integer

Private Sub Timer1_Timer()
n = n + 1
If n = 1 Then
Command1.Caption = "你好"
ElseIf n = 2 Then
Command1.Caption = "hello"
ElseIf n >= 3 Then
Command1.Caption = "喂"
n = n - 3
End If
End Sub

if timer.value mod 3=0 then
Command1.Caption="你好"
end if
if timer.value mod 3=1 then
Command1.Caption="hello"
end if
if timer.value mod 3=2 then
Command1.Caption="喂"
end if