-
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?
-
-
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.
-
What are the vars (strings....arrays...) ?
post the class desc...
-
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?
-
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.
-
I understand what you mean,
but in the code, how do I attach the 2 strings together? can I just use + or something?:(
-
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!
-
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!!!