I'm using an old Paradox database along with an older Delphi program I inherited and it keeps giving me a Number is out of range error when I hit this statement:
POE_Data.OrdersTaxRate.AsFloat:= StrToFloat(Copy(TaxRateLabel.Caption, 1,1));
The TaxRateLabel.Caption
equals 7%, and so the StrToFloat
is passing just the 7 character. The TaxRate field is defined in the database as a BCD field with 2 decimal places. I don't see any minimum or maximum values set in the database, so why is this producing the number out of range error?
In Delphi XE there is a AsBcd
property. You can use it together with StrToBcd function, which converts string to TBcd
:
POE_Data.OrdersTaxRate.AsBcd:= StrToBcd(Copy(TaxRateLabel.Caption, 1,1));