Good day all
I do not know what is the control to add the time in my text box? I have made a window form application simple game that you have to click buttons for 30 seconds. The application works except to view the time.
I think I did put the textBox2 line at the right place but I don't know what to write as command after in order to see the variable "intTimerCounter"?
Here is part of the code and I have put question mark where I seem to miss info.
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
// Update the timer
intTimerCounter++;
textBox2->???? = intTimerCounter;
if( intTimerCounter == 30 )
{
// If the timer reaches 30, disable
// the buttons
button1->Enabled = false;
button2->Enabled = false;
Thank you in advance
Last edited by Viper; 07-18-2006 at 06:52 AM. Reason: I'm french and now it will sounds better
Ahh, this is managed C++? .NET 2.0?
Your timer interval is in seconds and you just want to display time left?
Code:private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) { // Update the timer intTimerCounter++; textBox2->Text = System::ConvertToString(30 - intTimerCounter); if( intTimerCounter == 30 ) { // If the timer reaches 30, disable // the buttons button1->Enabled = false; button2->Enabled = false;
Thanks NeedHelp
Your line make sense. I changed "ConvertToString" to "Convert" since Intellisense does not recognize ConvertToString. I did both but came with an error.
The command textBox2->Text is to see text only. Would it be another command to see a variable or a timer in a text box?
P.S. Sorry I see my post should have been in the Managed C++. Maybe a MODO could transfer my post.
Thank you
Hey Viper,
I just loaded VC++ 2005 (.NET 2.0) and textBox1->Text is correct.
Here is the function I used:
He does have the Convert wrong. It should be Convert::ToString();Code:private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->Text = "Test"; }
PS: Moving to Managed C++ ForumCode:textBox2->Text = Convert::ToString(30 - intTimerCounter);
It works
Thank you NeedHelp and Jordan, I really appreciated your help.
Just out of curiosity, what were you creating?
DirkFirst Tutorials | Linux Forum
Three buttons: start, left and right
Simply a windows with two buttons that you click in intervals for 30 sec after pressing the start button.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks