im new to programming and i'm unsure why this wont work:
procedure TGIFtest.Edit1Change(Sender: TObject);
var
Text : integer;
begin
if text < 5 then
shape1.brush.Color := clred
else
if text >= 5 then
shape1.brush.Color := clgreen;
end;
I want the shape to be red when a number entered in the edit is less than 5, and green if a number 5 or higher is entered. Thanks.
The variable
Text
is not initialized, so you will have a random value.If you want to have the integer value from the Edit text (string), then you have to get this text and convert it to an integer value.
If the Edit text can not converted to an integer, an exception is raised.
To avoid this you can use
StrToIntDef
orTryStrToInt