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

    Simple windows form timer problem

    Im trying to make a simple timer that adds to a label every second. I can do this in VB, but I dont exactly know the syntax for VC. Im using Visual Studio 2003.

    Here is how I do it in VB. The "Seconds" variable is declared globally because other functions refference it.
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim Secs As Long
            Secs = DateDiff(DateInterval.Second, dStart, DateTime.Now)
            Seconds = Secs
            lblTime.Text = Secs
    End Sub
    Could someone please tell me how to do this in VC++?

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Simple windows form timer problem

    I suggest you to grab a Managed/C++ book to learn the basics of C++ and Managed/C++ syntax.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Feb 2006
    Posts
    32

    Re: Simple windows form timer problem

    The syntax isnt the problem, I simply dont know the C++ equivilant to the DateDiff function. I checked the msdn and found the CTime stuff to be a little confusing. And yes you are right I do need to order a book, I'll check amazon later today.

  4. #4
    Join Date
    Feb 2006
    Posts
    32

    Re: Simple windows form timer problem

    Never mind I figured out how to do it without a DateDiff equivilant. I just set the stick interval to 100ms and have the timer add .1 to a double every tick.

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