本文介绍了Pocket PC中无毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我用Timer编写Pocket PC应用程序. (Pocket Pc App中没有System.Time).所以我使用Window Timer.我感到惊讶,因为没有毫秒,并且已经返回零.所以我怎么得到毫秒.有人说使用Environment.TickCount.但是我不知道该如何使用,所以请尽可能帮我. :-\

Hello, i write the Pocket Pc Application with Timer. ( There is no System.Time in Pocket Pc App). So I user Window Timer. i amazed ''cause there is no milliseconds and already return zero. So how do i get millisecond. Somebody said use the Environment.TickCount. But i don''t know how do i use so help me if possible. :-\

推荐答案

Dim startTickCount As Int32 = Environment.TickCount

''Do something here

Dim endTickCount As Int32 = Environment.TickCount



一旦获得了这两个值,就可以使用以下函数来确定经过的毫秒数.



Once you have these two values you could use the following function to determine the number of milliseconds elapsed.

Public Function ElapsedMilliseconds(ByVal StartTickCount As Int32, ByVal EndTickCount As Int32) As Int32
    Dim elapsedTime As Int32 = 0
    If StartTickCount > EndTickCount Then
        elapsedTime = (Int32.MaxValue - StartTickCount) + (EndTickCount - Int32.MinValue)
    Else
        elapsedTime = EndTickCount - StartTickCount
    End If
    Return elapsedTime
End Function


Dim stopWatch as new StopWatch()

Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
       stopWatch.Start()
   
       Dim ts As TimeSpan = stopWatch.Elapsed
       Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)

        txtTimer.Text = elapsedTime
End Sub


这篇关于Pocket PC中无毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:13