Sub TextArea1_TextChanged (Old As String, New As String)
EditMaskCashRegister(TextArea1, Old, New)
End Sub
'automatically adds/moves decimal point for 0.00 format
Sub EditMaskCashRegister(ViewHandle As EditText, Old As String, New As String)
'remove existing decimal point, leaving string of digits
Dim Temp As String = New.Replace(".", "")
'remove excess leading zeroes
Do While Temp.Length > 3
If Temp.CharAt(0) = "0" Then
Temp = Temp.SubString(1)
Else
Exit
End If
Loop
'ensure at least three digits
Do While Temp.Length < 3
Temp = "0" & Temp
Loop
Dim DigitsBefore As Int = Temp.Length - 2
'insert decimal point
Temp = Temp.SubString2(0, DigitsBefore) & "." & Temp.SubString(DigitsBefore)
If Temp <> New Then
Log(New & " ==> " & Temp)
'put field back to view
ViewHandle.Text = Temp
'postion cursor at end
ViewHandle.SelectionStart = Temp.Length
End If
End Sub