# input number with decimal point • ### Question

• This is a sample for input numbers with decimal point in a textbox. At the End the program round the number with 2 numbers after the decimal point.

show ZKW930

If you have a better routine, please send it.

2012/11/26

Uuuh, there was a mistake by numbers with no or one numbers after the decimal point.

the corection program is ZKW930-0

Best Regards Martin

• Edited by Monday, November 26, 2012 4:54 PM
• Changed type Monday, November 26, 2012 4:56 PM
Saturday, November 24, 2012 2:37 PM

• litdev, that was very clever!

Although it's more of a SB's glitch, which doesn't remove excessive zeros after normal arithmetic operations.

But it does remove them when using Math's category functions!

So, just for the sake of completeness, I've also added the dot-to-comma display snippet:

`num = -162.295dec = 2Decimal()Commas()TextWindow.WriteLine("")Sub Decimal    tmp = Math.Power(10, dec)  num = 1/tmp * Math.Round(num * tmp)  EndSubSub Commas    dot = Text.GetIndexOf(num, ".")    If dot = 0 Then    TextWindow.Write(num)  Else    TextWindow.Write( Text.GetSubText(Num  1, dot-1) )    TextWindow.Write( "," + Text.GetSubTextToEnd(Num, dot+1) )  EndIf  EndSub`

Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

• Edited by Monday, November 26, 2012 9:17 PM
• Marked as answer by Tuesday, November 27, 2012 3:33 AM
Monday, November 26, 2012 8:59 PM

### All replies

• Best Regards Martin

Monday, November 26, 2012 4:58 PM
• Hello Martin!

Here's a very basic decimal point formatting snippet.

Though it does not fill in zeros to right nor replaces points w/ commas. Needs more code for it!  :P

```num = 162.2883
dec = 2

Decimal()

TextWindow.WriteLine(num)

Sub Decimal

tmp = Math.Power(10, dec)
num = Math.Round( num * tmp ) / tmp

EndSub```

Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

Monday, November 26, 2012 7:56 PM
• This puts the zeros after point
```num = 162.0
dec = 2
Decimal()
TextWindow.WriteLine(num)
Sub Decimal
tmp = Math.Power(10, dec)
num = 1/tmp * Math.Round( num * tmp )
EndSub```

Monday, November 26, 2012 8:27 PM
• litdev, that was very clever!

Although it's more of a SB's glitch, which doesn't remove excessive zeros after normal arithmetic operations.

But it does remove them when using Math's category functions!

So, just for the sake of completeness, I've also added the dot-to-comma display snippet:

`num = -162.295dec = 2Decimal()Commas()TextWindow.WriteLine("")Sub Decimal    tmp = Math.Power(10, dec)  num = 1/tmp * Math.Round(num * tmp)  EndSubSub Commas    dot = Text.GetIndexOf(num, ".")    If dot = 0 Then    TextWindow.Write(num)  Else    TextWindow.Write( Text.GetSubText(Num  1, dot-1) )    TextWindow.Write( "," + Text.GetSubTextToEnd(Num, dot+1) )  EndIf  EndSub`

Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

• Edited by Monday, November 26, 2012 9:17 PM
• Marked as answer by Tuesday, November 27, 2012 3:33 AM
Monday, November 26, 2012 8:59 PM