Private Sub Button1_Click
Dim sample As String
sample = formatLine("Low cost item", 100)
Log(sample & " : Line length = " & sample.Length)
sample = formatLine("Medium cost item", 10000)
Log(sample & " : Line length = " & sample.Length)
sample = formatLine("High cost item", 100000)
Log(sample & " : Line length = " & sample.Length)
sample = formatLine("High cost item", 1000000)
Log(sample & " : Line length = " & sample.Length)
End Sub
Private Sub formatLine(item As String, price As Float) As String
Dim cost As String = SetFormmatter(price, 12, 0)
Dim lineLength As Int = item.Length + cost.Length
Do While (lineLength < 40) ' Choose your line length HERE
item = item & " "
lineLength = item.Length + cost.Length
Loop
Return item & cost
End Sub
Public Sub SetFormmatter(Value As Float, Integers As Int, Fractions As Int) As String
Dim Formatter As B4XFormatter
Formatter.Initialize
Formatter.GetDefaultFormat.GroupingCharacter = "."
Formatter.GetDefaultFormat.DecimalPoint = ","
Formatter.GetDefaultFormat.MinimumIntegers = Integers
Formatter.GetDefaultFormat.MaximumFractions = Fractions
Formatter.GetDefaultFormat.MinimumFractions = Fractions
Formatter.GetDefaultFormat.Prefix = "$"
Formatter.GetDefaultFormat.IntegerPaddingChar = " "
Return Formatter.Format(Value)
End Sub