Android Question double decimal

Erel

B4X founder
Staff member
Licensed User
Longtime User
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
 
Upvote 0

Kiran Raotole

Active Member
Licensed User
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
Thanks.
 
Upvote 0
Top