Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

C++ Project

  • 20-01-2011 07:25PM
    #1
    Registered Users, Registered Users 2 Posts: 1,686 ✭✭✭


    Hi

    I am working on a vc++ project and I am having problem coding for a ticking clock.
    #include <time.h>
    
    String^ getClock()
    	{
    		SYSTEMTIME date;//@SYSTEMTIME: Specifies a date and time, using individual members for the month, day, year, weekday, hour, minute, second, and millisecond. 
                    GetSystemTime(&date);//@GetSystemTime: Function that retrieves the current system date and time.
    		String^ clock;
    
    		int theSec(date.wSecond);
    		int theMin(date.wMinute);
    		int theHour(date.wHour);
    
    		
    		clock = Convert::ToString(theHour+":"+theMin+":"+theSec);
    
    		return clock;
    	}
    

    I tried using the timer->tick but I got tones of error.


Comments

  • Registered Users, Registered Users 2 Posts: 1,686 ✭✭✭RealistSpy


    I can't get the clock to tick


  • Registered Users, Registered Users 2 Posts: 1,686 ✭✭✭RealistSpy


    Mark this as solved very silly fix.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    What's the fix? Somebody is going to come here looking for an answer.


  • Registered Users, Registered Users 2 Posts: 1,686 ✭✭✭RealistSpy


    //timer-tick event handler
    private: System::Void timer_Tick(System::Object^  sender, System::EventArgs^  e) {
    
                    //needs to be called in a timer-tick event handler
    		SYSTEMTIME date;//@SYSTEMTIME: Specifies a date and time, using individual members for the month, day, year, weekday, hour, minute, second, and millisecond. 
    		GetSystemTime(&date);//@GetSystemTime: Function that retrieves the current system date and time.
    
    		String^ clock;
    
    		int theSec(date.wSecond);
    		int theMin(date.wMinute);
    		int theHour(date.wHour);
    
    		clock = Convert::ToString(theHour+":"+theMin+":"+theSec);
    
    	        clockToolStripStatusLabel->Text = Convert::ToString(clock);
    		 }
    


Advertisement