+ Reply to Thread
Results 1 to 7 of 7

Thread: Problem adding timer in a text box

  1. #1
    Newbie Viper is an unknown quantity at this point Viper's Avatar
    Join Date
    Jul 2006
    Posts
    15

    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 08:52 AM. Reason: I'm french and now it will sounds better

  2. #2
    Programming God NeedHelp is on a distinguished road
    Join Date
    May 2006
    Posts
    526
    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;
    I Need Help

  3. #3
    Newbie Viper is an unknown quantity at this point Viper's Avatar
    Join Date
    Jul 2006
    Posts
    15
    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

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97
    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

  5. #5
    Newbie Viper is an unknown quantity at this point Viper's Avatar
    Join Date
    Jul 2006
    Posts
    15
    It works

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

  6. #6
    Programming Expert dirkfirst is on a distinguished road
    Join Date
    May 2006
    Posts
    354
    Just out of curiosity, what were you creating?
    DirkFirst

  7. #7
    Newbie Viper is an unknown quantity at this point Viper's Avatar
    Join Date
    Jul 2006
    Posts
    15
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Glass text - Photoshop
    By ahsan16 in forum Photoshop Tutorials
    Replies: 4
    Last Post: 06-30-2009, 08:34 AM
  2. [C] Comparison problem
    By Alhazred in forum C and C++
    Replies: 1
    Last Post: 08-29-2007, 04:58 AM
  3. HTML table vertical aligning problem
    By Carrym in forum HTML Programming
    Replies: 2
    Last Post: 03-22-2007, 10:04 PM
  4. HTML Basic Formatting
    By clookid in forum Tutorials
    Replies: 14
    Last Post: 03-06-2007, 03:10 PM
  5. Generate text with transparent background
    By AfTriX in forum PHP Tutorials
    Replies: 1
    Last Post: 01-08-2007, 02:13 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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