代码如下:
for x:=1 to 12 do
begin
a:=random(x);
edit2.Text:=players[a];
array1[1]:=a;
end;
显示如下错误:
Project Project1.exe raised exception class EAccessViolation with
message'Access violation at address 004042b3 in module
''Project1.exe'.Read of address FFFFFFF'.Process stopped.Use Step or Run to continue.
如果把array1[1]:=a;删掉,就没有错误了.
for x:=1 to 12 do
begin
a:=random(x);
edit2.Text:=players[a];
array1[1]:=a;
end;
显示如下错误:
Project Project1.exe raised exception class EAccessViolation with
message'Access violation at address 004042b3 in module
''Project1.exe'.Read of address FFFFFFF'.Process stopped.Use Step or Run to continue.
如果把array1[1]:=a;删掉,就没有错误了.
能不能多贴点代码
关于array1?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
players:array[1..12] of String;
array1:array[1..12] of Integer;
var
x:integer;
a,b,c,d,e,f,g,h,i,j,k,l:integer;
//a:integer;begin
begin
players[1]:='张文锋';
players[2]:='李金明';
players[3]:='顾群';
players[4]:='皮条';
players[5]:='小波';
players[6]:='小亮';
players[7]:='召华';
players[8]:='正锐';
players[9]:='老土';
players[10]:='任超';
players[11]:='孙剑';
players[12]:='苗子';
end;for x:=1 to 12 do
begin
a:=random(x);
array1[1]:=a;
edit2.Text:=players[a];end;
b:=random(x);
array1[2]:=b;
edit3.Text:=players[b];
c:=random(x);
array1[3]:=c;
edit4.Text:=players[c];
d:=random(x);
array1[4]:=d;
edit5.Text:=players[d];
e:=random(x);
array1[5]:=e;
edit6.Text:=players[e];
f:=random(x);
array1[6]:=f;
edit7.Text:=players[f];
g:=random(x);
array1[7]:=g;
edit8.Text:=players[g];
h:=random(x);
array1[8]:=h;
edit9.Text:=players[h];
i:=random(x);
array1[9]:=i;
edit10.Text:=players[i];
j:=random(x);
array1[10]:=j;
edit11.Text:=players[j];
k:=random(x);
array1[11]:=k;
edit12.Text:=players[k];
l:=random(x);
array1[12]:=l;
edit13.Text:=players[l];
end;
end.