delphi自定义函数该怎么声明?
unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
implementation
{$R *.dfm}
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
bgein
result:=x+y+z;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
isum:integer;
begin
isum:=getsum;
isum:= getsum(10,20,30);
end;
end.
[错误] Unit1.pas(29): Unknown directive: 'bgein'
[错误] Unit1.pas(30): Unknown directive: 'result'
[严重错误] Project1.dpr(5): Could not compile used unit '新建文件夹\Unit1.pas'
不知道那里错了,请高手指点! 展开
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
implementation
{$R *.dfm}
Function getsum(x:integer=20; y:integer=30;z:integer=40):integer;
bgein
result:=x+y+z;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
isum:integer;
begin
isum:=getsum;
isum:= getsum(10,20,30);
end;
end.
[错误] Unit1.pas(29): Unknown directive: 'bgein'
[错误] Unit1.pas(30): Unknown directive: 'result'
[严重错误] Project1.dpr(5): Could not compile used unit '新建文件夹\Unit1.pas'
不知道那里错了,请高手指点! 展开
1个回答
展开全部
定义函数,放到全局变量前面去;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
TableDI
2024-07-18 广告
2024-07-18 广告
VLOOKUP是Excel中用于垂直查找的函数,其基本用法包括四个参数:1. 查找值:即在数据表首列中需要搜索的值。2. 数据表:包含查找值的单元格区域或数组。3. 返回值所在列数:指定返回查询区域中第几列的值。4. 查找方式:选择精确匹配...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询