vb.netの12、11、10、9、8から12、11、10、09、08

レオ・エルヴィン・リー

タイマーはこのようにカウントダウンします14、13、12、11、10、9カウントダウンするときに9から09を作成するにはどうすればよいのでしょうか、11、10、09、08、07-00、i 'のようになります。ゴーグルを試しましたが、検索用のキーワードが正確ではありません

タイマーのマイコード

        Timer1.Interval = 1000
    If hours_label.Text = "" Then
        hours_label.Text = "0"
    End If
    If minutes_label.Text = "" Then
        minutes_label.Text = "0"
    End If
    If seconds_label.Text = "" Then
        seconds_label.Text = "0"
    End If
    If hours_label.Text = "00" Then
        hours_label.Text = "0"
    End If
    If minutes_label.Text = "00" Then
        minutes_label.Text = "0"
    End If
    If seconds_label.Text = "00" Then
        seconds_label.Text = "0"
    End If
    If seconds_label.Text > "0" Then
        seconds_label.Text = seconds_label.Text - 1
    End If
    If minutes_label.Text > "0" Then
        If seconds_label.Text = "0" Then
            minutes_label.Text = minutes_label.Text - 1
            seconds_label.Text = "59"
        End If
    End If
    If hours_label.Text > "0" Then
        If minutes_label.Text = "0" Then
            If seconds_label.Text = "0" Then
                hours_label.Text = hours_label.Text - 1
                minutes_label.Text = "59"
                seconds_label.Text = "59"
            End If
        End If
    End If
    If hours_label.Text = "0" Then
        If minutes_label.Text = "0" Then
            If seconds_label.Text = "0" Then
                Timer1.Enabled = False
                msgbox("Times Up")
                Screen_Locker.Show()
                Me.Close()
            End If
        End If
    End If

よろしくお願いします

コーディングビズ

これはあなたに有利スタートを与えるはずです:PadLeft関数を使用してください

Dim i As Integer = 15
While i >= 0
    Console.WriteLine(i.ToString().PadLeft(2, "0"c))
    i = i - 1
End While

仕組み:値が2桁の場合(例:14)は同じですが、1桁の場合は、その前に「0」を追加して2桁にします(2文字の文字列)

12 = 12
11 = 11
10 = 10
 9 = 09
...
 0 = 00

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事