Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to allign text in a Showmessage() call 1

Status
Not open for further replies.

Bachatero

Programmer
Aug 30, 2006
36
NL
Hi all,

How can I allign the text so that "FloatToStrF(out[x],ffFixed, 10, 3)" starts at the same lefthand position without using spaces in ("Ave: ") at every line?

Now, FloatToStrF(out[x],ffFixed, 10, 3) has no fixed position on the x-axis.

ShowMessage( "Ave: " + FloatToStrF(out[0],ffFixed, 10, 3) + "\n" +
"Stdev: " + FloatToStrF(out[1],ffFixed, 10, 3) + "\n" +
"Sqrt(rms): " + FloatToStrF(out[2],ffFixed, 10, 3) + "\n" +
"Max: " + FloatToStrF(out[3],ffFixed, 10, 3) + "\n" +
"Min: " + FloatToStrF(out[4],ffFixed, 10, 3) + "\n" +
"Max - Min: " + FloatToStrF(out[5],ffFixed, 10, 3) + "\n" +
"Ave Abs: " + FloatToStrF(out[6],ffFixed, 10, 3) + "\n" +
"Max Abs: " + FloatToStrF(out[7],ffFixed, 10, 3));

Thanks in advance!

Johan

 
I don't know of a way to right justify the text. I suspect that you may have to create a function that will take a couple of numbers and return a right justified string. Maybe something like:
Code:
AnsiString RightJustStr(double SomeNumber, int PlacesNumber)
{
    AnsiString TempStr = FloatToStr(SomeNumber, ffFixed, 10, 3);
    while (TempStr.Length() < PlacesNumber) TempStr = " " + TempStr;
    return TempStr;
}

Of course, you could add variables to replace the 10 and 3 to make the function more flexible.



James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top