Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27074

VS 2010 time format

$
0
0
Hi all.

I have a timer control, a label and 3 buttons(start, stop, reset) on my form. In the label I have 0 as the text. The timer interval is 1 second and the handler increments the label text by 1. How can I display and update the time as hh:mm:ss in the label?

Thanks in advance.

EDIT: Would using ToLongTimeString() work?

Code:

Public Class Form1


    Private Sub bttnStart_Click(sender As System.Object, e As System.EventArgs) Handles bttnStart.Click
        Timer1.Interval = 1000
        Timer1.Enabled = True
       
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = CInt(Label1.Text) + 1
    End Sub

    Private Sub bttnStop_Click(sender As System.Object, e As System.EventArgs) Handles bttnStop.Click
        Timer1.Enabled = False
    End Sub

    Private Sub bttnReset_Click(sender As System.Object, e As System.EventArgs) Handles bttnReset.Click
        Timer1.Enabled = False
        Label1.Text = 0
    End Sub
End Class


Viewing all articles
Browse latest Browse all 27074

Trending Articles