一个delphi的关键问题,求解答!!
unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
a=array of integer //自定义一个数组类型,此处报错了
edt1: TEdit;
btn1: TButton;
Function turnout(s:string):a;//申明一个返回值为数组类型的function,作用:分割字符串成一个个数组并返回,如在edit控件中输入10 25 36 5,该函数自动将字符串以空格为分隔符分割成单个数字存在数组中!!
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i:Integer=1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
ass:a;
k:Integer;
begin
turnout(edt1.text);
for k:=1 to i do //依次输出 返回的数组
edt1.Text:=edt1.Text+' '+IntToStr(ass);
end;
Function tform1.turnout(s:string):a;
var
as:a;
begin
s:=Trim(s); //去首尾空格
while pos(' ',s)<>0 then // 以空格为分割符,分割字符并存在as数组中
begin
as :=StrToInt(Copy(s,1,pos(' ',s)-1));
i:=i+1;
Delete(s,1,pos(' ',s));
end;
ifpos(' ',s)=0 then //最后一个字符串复制到数组中
as=StrToInt(s);
Result:=as; //返回整形数组
end;
end.
求大牛解答,多谢,感激不尽!!!!!!
页:
[1]