B4PPC and decimal comma

Scubaticus

Active Member
Licensed User
Here in the Netherlands we don't use the point but comma as our digit sign.
Normally this is controlled by local setting in windows (I use an english version with local setting to dutch). In, for example excel, this is working normally. In B4PPC however it seems it only will eat the point as decimal point.

So moving a textbox1.text with 51.5 to a cNumber cell, the value will be 51.5
When using 51,5 the cell has the value 515

When the first 51.5 however is shown in the table, when I display it in a form it fomrats as 51,5.

This both on my PC and PPC.

I fixed this by change the comma into a point when the field value changes, but that seems a very strange way to me.

:sign0085:

Scub
 

specci48

Well-Known Member
Licensed User
Is it possible to use the device format generally so that I can do something like this:

B4X:
a = 16,5
b = 3
c = a / b

specci48
 

Scubaticus

Active Member
Licensed User
The Table control will show numbers (cNumber fields) using the device format.
Well, this is no limitation for me as it behaves the way it should. I want a decimal comma and see a decimal comma. But how obout the input of 51.5 versus 51,5? It seems on the input there's a limitation?

Scub
 

specci48

Well-Known Member
Licensed User
With the input of 51.5 the point is handled as a decimal point so the variable value is 51.5.
With the input of 51,5 the comma is handled like a thousand separator (as in 123,456.78) which is of no use when the data is stored in a numeric variable. So the variable value is 515.


specci48
 

Cableguy

Expert
Licensed User
With the input of 51,5 the comma is handled like a thousand separator (as in 123,456.78) which is of no use when the data is stored in a numeric variable. So the variable value is 515.
If , is the thousands shouldnt 51,5 become 51500?
 

specci48

Well-Known Member
Licensed User
No, because the (useless) commas were only deleted. There's no converter or formatter adding possible trailing zeroes.
 

Scubaticus

Active Member
Licensed User
Sub Globals

End Sub

Sub App_Start
Form1.Show

table1.AddCol(cNumber,"cNumber",50)
table1.AddRow(0)

End Sub

Sub Button1_Click
table1.Cell("cNumber",0) = TextBox1.Text
End Sub
The above code, when entered 5.5 gives in the table 5,5
When entered 5,5 the table gives me 55

:SHOCKED:

Scub
 

specci48

Well-Known Member
Licensed User
This is a "normal" behaviour!

If you enter 5.5 we have a decimal point. So the value of the tablecell with format cNumber is 5.5. As Erel said, for showing the tablecontrol the control converts the values to the default device format. This is done only for the output. The internal variables still remain in the number format with decimal point.
If you enter 5,5 the value of the tablecell gets 55 (only the comma is removed). Showing this value in the tablecontrol (there is no format conversion necessary) will result in 55.

specci48
 

Scubaticus

Active Member
Licensed User
This is a "normal" behaviour!
"It's life Jim, but not as we know it, it's life"

I just have to get used to B4PPC, but it's going fast, thanks to all your quick replies! Well, still some problems to solve......:sign0151:

Scub.
 

RandomCoder

Well-Known Member
Licensed User
Scubaticus originally wrote
Here in the Netherlands we don't use the point but comma as our digit sign.
If you are worried that the comma might be used in the TextBox instead of a decimal place then you could try to catch and replace it before entering the number into the Table :)

Regards,
RandomCoder
 

Scubaticus

Active Member
Licensed User
catch and replace it before entering the number
into the Table :)
Well that's not enough. We also use the point as a thousand separator. I'll probable end up with a conversion sub.

Scub
 
Top