I want to change the text of label1 by multiplying query field with value of spinBox1. But it doesn't work. ** Fields[3] saved as Integer in my table **
label1.Text := MSQuery1.Fields[3].AsInteger * spinBox1.Value;
or
label1.Text := MSQuery1.Fields[3].AsInteger * spinBox1.Text.ToInteger;
CodePudding user response:
Assuming:
- Your application is FMX based then
Label1.Text
is okay, else you needLabel1.Caption
- SpinBox comes from FMX library, the
Value
type isDouble
, not anInteger
The code is:
Label1.Text := (MSQuery1.Fields[3].AsInteger * SpinBox1.Value).ToString;
// Or using older versions of Delphi
Label1.Text := FloatToStr(MSQuery1.Fields[3].AsInteger * SpinBox1.Value);
CodePudding user response:
You need Label1.caption
instead of Label1.Text
and it is a string, so you need IntToStr
function to convert integer (if it is integer) to string.