cummulative text

This is a discussion on cummulative text within the C++ Programming forums, part of the General Programming Boards category; I am using: Edit1->Text="A"; //some codes Edit2->Text="B"; //some codes and so on..... The Text in the edit box changed from ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    20

    cummulative text

    I am using:

    Edit1->Text="A";
    //some codes
    Edit2->Text="B";
    //some codes and so on.....

    The Text in the edit box changed from A to B to ....., what I really wanted was for the text to stay there ie
    A then AB, ABC...... ABCDEFGH......

    How can I do that?

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    use Text+="B"; ect.

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Forgot to say, if it does not allow u to do that, try to include string.h or define the += operator for strings. sorry about this I don't have a compiler w/me.

  4. #4
    Something Clever ginoitalo's Avatar
    Join Date
    Dec 2001
    Posts
    187
    What are the vars (strings....arrays...) ?

    post the class desc...

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    20
    I've tried the += and stringh, didn't work.
    And guys, I am lost! what do you mean be define += operator...
    , what do you mean what are the vars? and what is class desc?

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    to define the operator u need, try this

    string string operator+= (string)
    {//code here}

    or something like that. I have not done this in a while so I am not completely sure.

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    20
    I understand what you mean,
    but in the code, how do I attach the 2 strings together? can I just use + or something?

  8. #8
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    You want to include <string>

    ex
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    string s1,s2;
    s1 = "Hello";
    s2 = s1 + " world!";
    cout << s1 << endl;
    cout << s2 << endl;
    return 0;
    }
    that will print out
    Hello
    Hello world!

  9. #9
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343

    Thumbs up

    I assume that you use builder. In that case why doesnt you use AnsiString.

    ..
    ..
    ..
    AnsiString s1,s2,s3;
    s1 = Edit1->Text;
    s1 = Edit2->Text;
    s3 = s1 +s2;
    ...


    If you use the VCL componets they usually use AnsiString i.e property for Edit1->Text, Label1->Caption, Form1->Caption and so on.

    AnsiString is a class written for builder and is more easiers to use and manipulate (you got tons of functions for AnsiString) with than working with i.e arrays. Use AnsiString when working with strings!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 10:45 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21