Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to put a time counter in my vb.net project?

how to put a time counter in my vb.net project?

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rharzkie
    wrote on last edited by
    #1

    i am making a software "IQ TEST" for my thesis project... but my problem is i dont know how to put a timer in my module? can you pls tell me the codes for it??? thanks

    J 1 Reply Last reply
    0
    • R Rharzkie

      i am making a software "IQ TEST" for my thesis project... but my problem is i dont know how to put a timer in my module? can you pls tell me the codes for it??? thanks

      J Offline
      J Offline
      John_Adams
      wrote on last edited by
      #2

      Hi, Please try the following code snippet which uses a Timer Control (Timer1), one label (lblLogin) and two button (btnLogin and btnBreak). Drag and drop above mention .Net control and give name accordingly (as mentioned in the parenthesis) and paste the following code snippet: ------------------------------------------------------------------------- BEGIN CODE Public Class Form1 Dim tmr1 As Integer Dim timerString As String Dim seconds, minutes, hours As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.lbldate.Text = Format(Now(), "dddd, MMM dd yyyy") 'Me.btnLogin.Enabled = False Me.AcceptButton = btnLogin Me.Timer1.Start() ' End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'Me.lblLogin.Text = Format(Now(), "hh:mm:ss") 'tmr1 = tmr1 + 1 'timerString = tmr1 seconds += 1 If seconds = 60 Then minutes += 1 seconds = 0 End If If minutes = 60 Then hours += 1 minutes = 0 End If timerString = hours & ":" timerString = timerString & minutes & ":" timerString = timerString & seconds Me.lblLogin.Text = timerString End Sub Private Sub btnBreak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBreak.Click Me.Timer1.Stop() End Sub Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click Me.Timer1.Start() End Sub END CODE ------------------------------------------------------------------------- I hope this helps :).

      Regards, John Adams ComponentOne LLC

      R 1 Reply Last reply
      0
      • J John_Adams

        Hi, Please try the following code snippet which uses a Timer Control (Timer1), one label (lblLogin) and two button (btnLogin and btnBreak). Drag and drop above mention .Net control and give name accordingly (as mentioned in the parenthesis) and paste the following code snippet: ------------------------------------------------------------------------- BEGIN CODE Public Class Form1 Dim tmr1 As Integer Dim timerString As String Dim seconds, minutes, hours As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.lbldate.Text = Format(Now(), "dddd, MMM dd yyyy") 'Me.btnLogin.Enabled = False Me.AcceptButton = btnLogin Me.Timer1.Start() ' End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'Me.lblLogin.Text = Format(Now(), "hh:mm:ss") 'tmr1 = tmr1 + 1 'timerString = tmr1 seconds += 1 If seconds = 60 Then minutes += 1 seconds = 0 End If If minutes = 60 Then hours += 1 minutes = 0 End If timerString = hours & ":" timerString = timerString & minutes & ":" timerString = timerString & seconds Me.lblLogin.Text = timerString End Sub Private Sub btnBreak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBreak.Click Me.Timer1.Stop() End Sub Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click Me.Timer1.Start() End Sub END CODE ------------------------------------------------------------------------- I hope this helps :).

        Regards, John Adams ComponentOne LLC

        R Offline
        R Offline
        Rharzkie
        wrote on last edited by
        #3

        thanks, but can this timer can stop in another form? for example, your timer starts at form1, the timer is only set in 60 minutes. When 60 min. is over and you are in the form3 already.. it will go automatically to the last form (form10 for example). is it possible?

        G 1 Reply Last reply
        0
        • R Rharzkie

          thanks, but can this timer can stop in another form? for example, your timer starts at form1, the timer is only set in 60 minutes. When 60 min. is over and you are in the form3 already.. it will go automatically to the last form (form10 for example). is it possible?

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Yes, of course. How it's done depends however very much on how you move from one form to another.

          Despite everything, the person most likely to be fooling you next is yourself.

          R 1 Reply Last reply
          0
          • G Guffa

            Yes, of course. How it's done depends however very much on how you move from one form to another.

            Despite everything, the person most likely to be fooling you next is yourself.

            R Offline
            R Offline
            Rharzkie
            wrote on last edited by
            #5

            ok! thanks! i got it already... thank you so much to all those who help! ;)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups