I have string 725517.5
I want its to show as 725517.50
I want its to show as 725517.50
Never use Round2. The correct answer is in the last post: https://www.b4x.com/android/forum/threads/double-type-decimals.63928/#post-404393
Sub FormatNumber (i As Int) As String
Dim n As String = NumberFormat2(i, 0, 0, 0, False)
Dim sb As StringBuilder
sb.Initialize
Dim NextGroup As Int = 3
For i = 0 To n.Length - 1
If NextGroup = 0 Then
sb.Insert(0, ",")
NextGroup = 2
End If
sb.Insert(0, n.CharAt(n.Length - 1 - i))
NextGroup = NextGroup - 1
Next
Return sb.ToString
End Sub
Thanks.B4X:Sub FormatNumber (i As Int) As String Dim n As String = NumberFormat2(i, 0, 0, 0, False) Dim sb As StringBuilder sb.Initialize Dim NextGroup As Int = 3 For i = 0 To n.Length - 1 If NextGroup = 0 Then sb.Insert(0, ",") NextGroup = 2 End If sb.Insert(0, n.CharAt(n.Length - 1 - i)) NextGroup = NextGroup - 1 Next Return sb.ToString End Sub