krishnaraj s

krishnaraj s

  • NA
  • 4
  • 7.6k

VB.Net Timer Control Using display current Time

Sep 14 2012 1:46 AM
Hi,

i am using vb.net 2010, Add 3 lables,3 button and timer control.i need 3 button click current time automatically updated.bellow i am using code.

code:

timer inverval define:1000

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Timer1.Start()
        Label1.Text = Add()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Timer1.Start()
        Label2.Text = Add()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Timer1.Start()
        Label3.Text = Add()

    End Sub
    
    Public Function Add() As String

        Dim s As String
        s = Now.ToString("HH:mm:ss")
        Return (s)

    End Function

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

        Call Add()

    End Sub