CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2001
    Posts
    14

    How to create a stopwatch?

    I want to create a running 'stopwatch' for my game program. the 'stopwatch' time should be shown in a label box. It should be function like "microsoft Minesweeper Game" timer.


  2. #2
    Join Date
    Jun 2000
    Location
    Nepal
    Posts
    108

    Re: How to create a stopwatch?

    put a timer control on your form, set its interval to 1000(milliseconds) set its enabled to false.

    Then

    private Sub Command1_Click()
    Timer1.Enabled = true
    End Sub
    private Sub Timer1_Timer()
    static cnt as Integer
    cnt = cnt + 1
    Label1.Caption = cnt
    End Sub




    You cannot make the timer tick more rapidly than once per 55 ms.


  3. #3
    Join Date
    Mar 2001
    Posts
    14

    Re: How to create a stopwatch?

    how do i disable the stopwatch timer with the same command button?


  4. #4
    Join Date
    Jun 2000
    Location
    Nepal
    Posts
    108

    Re: How to create a stopwatch?


    private Sub Command1_Click()
    Timer1.Enabled = Not Timer1.Enabled
    End Sub





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured