Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C++ Project

Options
  • 20-01-2011 7:25pm
    #1
    Registered Users 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 Posts: 1,686 ✭✭✭RealistSpy


    I can't get the clock to tick


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


    Mark this as solved very silly fix.


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


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


  • Registered Users 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