Hi all,
Is there way re-engineer the Magret'sStringFunction2 ? I know only it created by B4A. I used to see the sourcecode once the time.
The library is necessary for helping easy coding more times.
https://www.b4x.com/android/help/stringfunctions.html#stringfunctions_at
Please add Erel's Function,too.
Best Regards
Theera
Is there way re-engineer the Magret'sStringFunction2 ? I know only it created by B4A. I used to see the sourcecode once the time.
The library is necessary for helping easy coding more times.
https://www.b4x.com/android/help/stringfunctions.html#stringfunctions_at
Please add Erel's Function,too.
B4X:
'only tested with positive numbers
Private Sub FormatWithCustomGrouping(n As Double, DecimalPoints As Int) As String
Dim Groupings() As Int = Array As Int(3, 2, 1000)
Dim res As StringBuilder
res.Initialize
Dim i As Int = n
Dim s As String = i
Dim f As Double = (n - i) * Power(10, DecimalPoints)
res.Insert(0, NumberFormat2(f, DecimalPoints, 0, 0, False))
res.Insert(0, ".")
Dim index As Int = s.Length - 1
For Each g As Int In Groupings
Do While g > 0
If index < 0 Then Exit
res.Insert(0, s.CharAt(index))
g = g - 1
index = index - 1
Loop
If index >= 0 Then res.Insert(0, ",")
Next
Return res.ToString
End Sub
Best Regards
Theera
Last edited: