在VB中是没有毫秒级显示的,除非自己编,不过时钟控件不可能达到一秒1000次,我试过的了,把timer.interval=10 在事件里写如下代码试试, static i as long i=i+1 label1.caption=now() & ":" & i if i=10 then i=0试一下, 不知道行不行。
在VB中是没有毫秒级显示的,除非自己编,不过时钟控件不可能达到一秒1000次,我试过的了,把timer.interval=100 在事件里写如下代码试试, static i as long i=i+1 label1.caption=now() & ":" & i if i=10 then i=0试一下, 不知道行不行。
现在我如下处理。在视觉效果上是达到要求了。 Public t1, t2 As Long Public d1 As Date Public n1 As Integer Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command1_Click() '开始 按钮 If t1 = 0 Then t1 = GetTickCount End If Timer1.Enabled = True End SubPrivate Sub Command2_Click() '暂停按钮 Timer1.Enabled = False End SubPrivate Sub Command3_Click() '停止按钮 Timer1.Enabled = False t1 = 0 Label1.Caption = "" End SubPrivate Sub Form_Load() '初始 t1 = 0 t2 = 0 End SubPrivate Sub Timer1_Timer() 'inteval 设定为1毫秒 t2 = GetTickCount - t1 d1 = TimeSerial(0, 0, t2 / 1000) n1 = t2 Mod 1000 Label1.Caption = Format(d1, "hh:mm:ss") & ":" & n1 End Sub
i=i+1
label1.caption=now() & ":" & i
if i=10 then i=0试一下, 不知道行不行。
Public t1, t2 As Long
Public d1 As Date
Public n1 As Integer
Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command1_Click() '开始 按钮
If t1 = 0 Then
t1 = GetTickCount
End If
Timer1.Enabled = True
End SubPrivate Sub Command2_Click() '暂停按钮
Timer1.Enabled = False
End SubPrivate Sub Command3_Click() '停止按钮
Timer1.Enabled = False
t1 = 0
Label1.Caption = ""
End SubPrivate Sub Form_Load() '初始
t1 = 0
t2 = 0
End SubPrivate Sub Timer1_Timer() 'inteval 设定为1毫秒
t2 = GetTickCount - t1
d1 = TimeSerial(0, 0, t2 / 1000)
n1 = t2 Mod 1000
Label1.Caption = Format(d1, "hh:mm:ss") & ":" & n1
End Sub