在vb中如何有一个text,一个timer和一个command编写一个程序,打点击command时,text中的显示为时间变化,
例如:timer的interval属性为1000时,text中的显示为按秒逐步显示····
追问:希望只得到计时用的即可,并不是当时时间的显示,谢谢了····
例如:timer的interval属性为1000时,text中的显示为按秒逐步显示····
追问:希望只得到计时用的即可,并不是当时时间的显示,谢谢了····
答案:Private Sub Command1_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Form_load()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Static a As Long
Static b As Long
Static c As Long
a = a + 1
If a > 59 Then
a = 0
b = b + 1
ElseIf b > 59 Then
b = 0
c = c + 1
End If
Text1.Text = "已经过了" & c & "小时" & b & "分" & a & "秒"
End Sub
其他:Private Sub Command1_Click()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Text1.Text = Time
End Sub
上一个:VB 浏览电脑文件然后把选择的信息返回到Text中.怎么防止生成Exe文件中的Text被修改
下一个:VB6.0中如何停止运行以下脚本