Addition doesn't add, it appends
Posted on 2009-04-25
I'm using Visual Basic 6 and my project is simple: Have the user enter 18 values in the screen, total what the user has enter and show it in the screen. That's it.
However, I keep getting a "Run-Time error '13' , Mismatch'" message at some fvariables being added in the calculation and I don't know what it is.
I have the following screen fields (its a total of 18):
At each fields' LostFocus & GotFocus, the screen data is passed to Currency type variables:
DiffinCoop = txtDiffinCoop.Text
DiffinOffers = txtDiffinOffers.Text
DIffinPrice = txtDIffinPrice.Text
DiffinWeight = txtDiffinWeight.Text
At each fields' LostFocus & GotFocus, the variables are added to Currency tpe variable:
TotalDiscount = DiffinCoop
TotalDiscount = TotalDiscount + DiffinOffers
TotalDiscount = TotalDiscount + DIffinPrice
TotalDiscount = TotalDiscount + DiffinWeight
The variable TotalDiscount adds each time the user jumps to any specific field, and adds corretly. But when TotalDiscount adds DiffinCoop, it gives me a "Run-Time error '13' , Mismatch'" message.
I have Debug it and if I enter to 2 fields, it works, to 3 it works, but when I enter values at txtDiffinCoop.Text, it gives me an error.
When seeing the value in TotalDiscount , it shows the data enter as Appended. IF the user enter for each field 1.00, 23.00, 4.22, 34.09, when the routine for TotalDiscount is run, the value in TotalDiscount is "1.0023.004.2234.09".