TextBox.Text Average?

cdeane

Member
How do I get a average of .125 or less In a TextBox?
And can I center the text in a TextBox?
 

cdeane

Member
Thanks for the text alignment help Erel.

By average I mean that I get something like 50.1246887 in my TextBox but I need
50.125.
If I resize the TextBox to fit then I may need a diffrent value at some point like 23.5 in which case the TextBox would then read 23.495 which I do not need.
 

BerndB

Member
Licensed User
Hi cdeane,

What you need, I think, is
round(yourValue,3)
for 3 digits.

val = 56.123432
textbox.text = round(val,3)
delivers 56.123

I hope I'm right and this helps

regards
Bernd
 

specci48

Well-Known Member
Licensed User
Longtime User
Or you can use the format function:

B4X:
Msgbox (Format(1234.5678,"N2"))

Will display: 1,234.57


specci48
 

cdeane

Member
I do not know what value the TextBox will throug out at any given time.

I need someting like : Round(TextBox.Text,2)
Which of course dose not seem to work.
 

klaus

Expert
Licensed User
Longtime User
It depends on what you want to do.

- do you want do display a variable like x=54.124678 but roundet with 3 digits after the decimal point ?
This is the case of both suggested solutions.
Ex. TextBox1.Text=Round(x,3)

- do you want to allocate the value in the TextBox to a variable but rounded ?
Ex. x=Round(TextBox1.Text,3)

- do you want the variable in the Textbox rounded during input ?
This would be somewhat more complicated, but you can use the Door library
and look at agrahams example of Uppercase in textbox or the livefilter example and adpt it to your requirement.
You will find this in:
http://www.b4x.com/forum/showthread.php?t=2183

Best regards
 

cdeane

Member
YES!
Your exatcly right Klaus.
I want it done at input. ei, TextBox1.Text=TextBox2.Text+TextBox3 ,then have it rounded out.

Ill see what the link will produce.
 

cdeane

Member
Thanks Klaus,
That looks like what Im looking for.
Much apreciation to every ones advice.
 
Top