0

間隔 = 1 のタイマーを取得しました

間隔 1 = 1 ミリ秒 ?

間隔 1 が 1 ミリ秒でない場合、
制御間隔 = 1 ミリ秒を教えてください

コード:

Imports System.Globalization

Public Class Form1
    'Default Time To Start From
    Dim time As String = "00:00:00,000" 'Start From Here

    'Label
    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        Timer1.Start() 'Run The Timer On Click
    End Sub

    'TIMER
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        'Timer Interval = 1

        Dim ci = CultureInfo.InvariantCulture

        Dim original As TimeSpan = TimeSpan.ParseExact(time, "hh\:mm\:ss\,fff", ci) 'ParseExact

        Dim difference As TimeSpan = TimeSpan.FromMilliseconds(1) ' = 1  Millisecond

        Dim final = original

        final = original + difference ' connect between original to difference !(00:00:00,000 + 1 MS = 00:00:00,001)!

        Dim output As String = final.ToString("hh\:mm\:ss\,fff", ci) 'convert to the format (  = 00:00:00,001  ) (Back It To The Right Format)

        time = output '!!Update!! the Time String from 00:00:00,000 To 00:00:00,001 |||| And in the Next Time 00:00:00,001 + 1 = 00:00:00,002

        Label1.Text = time 'Show the Time String in the label

    End Sub

End Class

ご覧のとおり、間隔1で通常のタイマー
を使用していますが、タイマーがミリ秒をカウントしていないため

、アドバイスがあれば教えてください。

4

2 に答える 2

1

MSDN の interval プロパティの説明は次のとおりです。

Tick イベントが最後に発生してから Tick イベントが発生するまでの時間をミリ秒単位で取得または設定します。

ただし(スティーブがコメントで指摘したように):

Windows フォーム タイマー コンポーネントはシングル スレッドであり、精度は 55 ミリ秒に制限されています。精度の高いマルチスレッド タイマーが必要な場合は、System.Timers 名前空間の Timer クラスを使用します。

http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspxから取得

参照されているSystem.Timers.Timerクラスについては、http: //msdn.microsoft.com/en-us/library/system.timers.timer.aspxで説明されています。

于 2012-06-14T11:04:59.623 に答える
-1
    Imports System.Globalization


Public Class Form1
    Dim time As String = "00:00:00:00"
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        Dim ci = CultureInfo.InvariantCulture

        Dim original As TimeSpan = TimeSpan.ParseExact(time, "dd\:hh\:mm\:ss", ci) 'ParseExact

        Dim difference As TimeSpan = TimeSpan.FromSeconds(1) ' = 1  Millisecond

        Dim final = original

        final = original + difference ' connect between original to difference !(00:00:00,000 + 1 MS = 00:00:00,001)!

        Dim output As String = final.ToString("dd\:hh\:mm\:ss", ci) 'convert to the format (  = 00:00:00,001  ) (Back It To The Right Format)

        time = output '!!Update!! the Time String from 00:00:00,000 To 00:00:00,001 |||| And in the Next Time 00:00:00,001 + 1 = 00:00:00,002

        Label1.Text = time 'Show the Time String in the label

    End Sub
End Class

これが作業スクリプトです。IDK なぜそれが機能するのですが、機能します! :)

于 2017-09-20T12:09:46.950 に答える