Android Question Counting Decimals = Invalid Double

GMan

Well-Known Member
Licensed User
Longtime User
Hoi,
i want to count decimals (here money), but got always erros.
it should simply add the lblPreis.Text(LabelText= i.e. 3.20) to Bestellsumme (Double= i.e. 2.20)

Here is the code i am using:
B4X:
Dim Bestellsumme as Double
lblPreis.Text= NumberFormat2(lblPreis.Text,0,2,2,False)
    Bestellsumme = NumberFormat2(Bestellsumme,0,2,2,False)
    Bestellsumme = Bestellsumme + lblPreis.Text
    lblSumme.Text = Bestellsumme
    lblSumme.Visible = True

The error message is:
java.lang.NumberFormatException: Invalid double:"3.20"

I tried around, but without knownledge its only try-and-error :confused:
 

GMan

Well-Known Member
Licensed User
Longtime User
I now changed to:
B4X:
Private Preis As Double = lblPreis.Text
    Bestellsumme = Bestellsumme + Preis
  
    lblSumme.Text = Bestellsumme

    lblSumme.Visible = True
but the error is the same ?!
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Got it - the Format of the Double is not guilty.
As i am using the comma-seperator, but the double uses the dot-seperator, i had to add simply the following:
B4X:
    lblPreis.Text = lblPreis.Text.Replace(".", "").Replace(",", ".") = THIS was missing
    Private Preis As Double = lblPreis.Text
    Bestellsumme = Bestellsumme + Preis
   
    lblSumme.Text = Bestellsumme

    lblSumme.Visible = True
 
Upvote 0
Top