Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Delphi function return value definition problem
Delphi function return value definition problem

The return value of the following integer definition function is an integer, and the integer in parentheses defines the two parameters i and j of the function as integers.

For example, the following function finds the sum of two numbers

function TForm1.MyFun(i, j: integer): integer;

begin

< p> result:= i+j; //The return value is the sum of the two parameters

end;

We can call it in the click event of the button

< p>procedure TForm1.Button1Click(Sender: TObject);

var

i: integer;

begin

i:= MyFun (3, 5); //Call the function to find the sum of 3 and 5, and assign the result to the integer variable i

showmessage('The sum of the two numbers is: '+ inttostr(i)); //Output The result of function calculation

end;