Error: "" is not a valid integer value
Solved
JordanP31
Posted messages
26
Registration date
Status
Member
Last intervention
-
Profile blocked -
Profile blocked -
Hello,
I wrote a small piece of code in Delphi and I have an error that appears: Exception class EConvertError with a message "" is not a valid integer value.
Any solution?
My code:
Configuration: Configuration: Windows / Firefox 52.0
I wrote a small piece of code in Delphi and I have an error that appears: Exception class EConvertError with a message "" is not a valid integer value.
Any solution?
My code:
procedure TForm1.bnSP98Click(Sender: TObject); var prixSP98: extended; quantite: extended; prixTotal: extended; begin; prixSP98 := 1.25; quantite := StrToInt(edQuantite.Text); prixTotal := StrToInt(edPrix.Text); prixTotal := quantite * prixSP98; edPrix.Text := FloatToStr(prixTotal); end;
Configuration: Configuration: Windows / Firefox 52.0
1 answer
-
1- Avoid the Extended type, stick to the Double type
2- If the variable Quantity receives indivisible objects, it's better to declare it as an integer Integer which is why there is an error in this line: quantity := StrToInt(edQuantity.Text); otherwise, the object Pascal respects typecasting, the predefined function StrToInt() returns an integer while Quantity is declared as a floating variable.
Const priceSP98 := 1.25;
var Quantity : integer;
TotalPrice : Double;
Quantity : StrToInt();
TotalPrice := Quantity * priceSP98;
TextPrice := FloatToStr(TotalPrice);