|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
tmp.rar
(162.12 KB, 下载次数: 5)
附件是实例代码,每次运行到给动态数组赋值的语句处就出错了,小弟初学,应该是犯了什么低级的错误,希望大侠指点一下,谢谢了,
以下是复制的代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
lbl1: TLabel;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
shuzu: Array of Integer; //申请一个动态数组
n: Integer =0 ;
i: Integer;
tmp: String;
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
begin
tmp:='123'; //字符串变量赋值
inc(n); //变量n加1
shuzu[n]:= StrToInt(tmp); //运行到到这里就出错了
for i:=1 to n do
begin
lbl1.Caption:= lbl1.Caption + IntToStr(shuzu[i]);
end;
end;
end.
|
|