Android Question Set number of decimal places

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
how can I set to 3, the number of decimal places in an EditText with INPUT_TYPE_DECIMAL?
 

Mahares

Expert
Licensed User
Longtime User
Would this do the job for you:
B4X:
Sub txtTest_FocusChanged (HasFocus AsBoolean)
  If IsNumber(txtTest.Text) Then
    If HasFocus=False Then
     ' txtTest.Text=NumberFormat(txtTest.Text,0,3) ' you can use this line as an alternative
      txtTest.Text=NumberFormat2(txtTest.Text,0,3,3,False)
    End If
  End If
End Sub
EDIT: I added the first if statement to avoid crash if box is left blank after lost focus
 
Last edited:
Upvote 0
Top