Hi,
I have many EditText which are numbers and I deal with it all the time no knowing what todo having many error of double"" and so on, no I got an unexpected Array, see image please and I just dont know how to program a simple caculation.
A routine like:
B4X:
Sub CalcTot
If eDias.Text>0 And eTasa.Text>0 Then
Dim d As Int
d=eDias.Text
DateTime.DateFormat="dd/MM/yyyy"
dVto.Text = DateTime.Date(DateTime.Add(DateTime.Now,0,0,d))
eIntereses.Text = (ePrecio.Text * eCantidad.Text) * (eTasa.Text/100) * d /365
eIntereses.Text = NumberFormat2(eIntereses.Text,0,2,2,True)
End If
dTotal.Text = (ePrecio.Text * eCantidad.Text) + eIntereses.Text
dTotal.Text = NumberFormat2(dTotal.Text,0,2,2,True)
can give an infinite number of errors if one of the components is "" or null or...
1) do not use views for calculations.
It is better to use variables, ALSO to keep separate GUI from the code;
So you should have:
Dim Dias As Int
Dias = eDias.Text
2) Verify the user input (in eDias, for example) and set the EditText.InputType
3) if you really want to test this way:
If eDias.Text > 0
you can use:
If "0" & eDias.Text > 0
given that a zero on the left does not change the numeric value.
Thanks Lucas, the idea of use
Dim Dias As Int
Dias = eDias.Text
that means a Dim and an assignment for each edittext in each activity... does it have any impact on perfomance?