| View previous topic :: View next topic |
| Author |
Message |
undbund Guest
|
Posted: Tue Apr 20, 2004 10:35 pm Post subject: Displaying in Memo |
|
|
Hi i have a small program which displays 5 numbers from 0 - 5, the code is:
for( int i = 0; i < 5; i++ )
{
Memo->Lines->Add(IntToStr(i));
}
The output in memo is:
0
1
2
3
4
How to display the output in this format?
0 1 2 3 4
thanx for all your help
undbund
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Tue Apr 20, 2004 11:40 pm Post subject: Re: Displaying in Memo |
|
|
undbund <undbund (AT) yahoo (DOT) com> wrote:
| Quote: | Hi i have a small program which displays 5 numbers from 0 - 5, the code is:
|
That would be 6 numbers <g>
| Quote: | [...] How to display the output in this format?
0 1 2 3 4
|
Add adds a line. What you want to do is to format a single line and it:
int Limit = 5;
AnsiString s = "";
for( int i = 0; i < Limit; ++i )
{
s += IntToStr( i );
if( i < Limit - 1 ) s+= " ";
}
Memo->Lines->Add( s );
~ JD
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Apr 21, 2004 5:33 am Post subject: Re: Displaying in Memo |
|
|
"undbund" <undbund (AT) yahoo (DOT) com> wrote
| Quote: | How to display the output in this format?
0 1 2 3 4
|
Alternatively to what JD suggested:
for( int i = 0; i < 5; i++ )
{
Memo->SelStart = Memo->GetTextLen();
Memo->SelLength = 0;
Memo->SelText = IntToStr(i) + " ";
if( i < 4 )
{
Memo->SelStart = Memo->GetTextLen();
Memo->SelLength = 0;
Memo->SelText = " ";
}
}
Gambit
|
|
| Back to top |
|
 |
|