Board index » delphi » Assign value to integer variables

Assign value to integer variables


2006-01-12 01:59:10 PM
delphi203
I know this is a basic question, but for newbie in delphi like me its
freakin me out :),
okay, the problem is i had an integer variables which i assign its
value from an TEdit, then if
the user doesnt fill a value on TEdit the program will assign it with
0,so i make a function like this
function TFProduct.getMMax: integer;
begin
if EditMMax.Text:=' ' then
result:=0
else
result:=StrToInt(EditMMax.Text) ;
end;
but its return an error message "Type of expression must be boolean"...
I know the problems is around the If Then Else expressions..
Any idea how to fix it..
Any help i appreciated.
Thanks.
Hars.
 
 

Re:Assign value to integer variables

Hars writes:
Quote
I know this is a basic question, but for newbie in delphi like me its
freakin me out :),
okay, the problem is i had an integer variables which i assign its
value from an TEdit, then if
the user doesnt fill a value on TEdit the program will assign it with
0,so i make a function like this

function TFProduct.getMMax: integer;
begin

if EditMMax.Text:=' ' then
result:=0
else
result:=StrToInt(EditMMax.Text) ;
end;

but its return an error message "Type of expression must be boolean"...
I know the problems is around the If Then Else expressions..
Any idea how to fix it..

Any help i appreciated.

Thanks.
Hars.

Try comparsion, not assignment, use next
if EditMMax.Text = '' then
reni
 

Re:Assign value to integer variables

Hars writes:
Quote
I know this is a basic question, but for newbie in delphi like me its
freakin me out :),
okay, the problem is i had an integer variables which i assign its
value from an TEdit, then if
the user doesnt fill a value on TEdit the program will assign it with
0,so i make a function like this

function TFProduct.getMMax: integer;
begin

if EditMMax.Text:=' ' then
result:=0
else
result:=StrToInt(EditMMax.Text) ;
end;

but its return an error message "Type of expression must be boolean"...
I know the problems is around the If Then Else expressions..
Any idea how to fix it..

Any help i appreciated.

Thanks.
Hars.

if EditMMax.Text=' ' then