Closed Thread
Results 1 to 7 of 7

Thread: Problem adding timer in a text box

  1. #1
    Viper Guest

    Problem adding timer in a text box

    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

  2. CODECALL Circuit advertisement

     
  3. #2
    NeedHelp Guest
    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;

  4. #3
    Viper Guest
    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

  5. #4
    Jordan Guest
    Hey Viper,
    I just loaded VC++ 2005 (.NET 2.0) and textBox1->Text is correct.
    Here is the function I used:

    Code:
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    	textBox1->Text = "Test";
    }
    He does have the Convert wrong. It should be Convert::ToString();

    Code:
    textBox2->Text = Convert::ToString(30 - intTimerCounter);
    PS: Moving to Managed C++ Forum

  6. #5
    Viper Guest
    It works

    Thank you NeedHelp and Jordan, I really appreciated your help.

  7. #6
    dirkfirst is offline Programming Expert
    Join Date
    May 2006
    Posts
    354
    Rep Power
    23
    Just out of curiosity, what were you creating?

  8. #7
    Viper Guest
    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.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. adding text in forum/email messages
    By omriliba in forum General Programming
    Replies: 2
    Last Post: 01-31-2011, 07:57 AM
  2. Adding Custom Text To An Image
    By chad in forum PHP Development
    Replies: 6
    Last Post: 02-19-2010, 12:09 AM
  3. Adding text to images script
    By Xhris in forum MarketPlace
    Replies: 7
    Last Post: 11-20-2008, 12:43 PM
  4. Help with adding numbers to text box.
    By xGhost4000x in forum Visual Basic Programming
    Replies: 3
    Last Post: 09-03-2008, 01:06 PM
  5. Problem adding timer in a text box
    By Viper in forum C and C++
    Replies: 3
    Last Post: 07-18-2006, 08:21 AM

Tags for this Thread

Bookmarks

Posting Permissions

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