
25.01.2010, 21:20
|
Прохожий
|
|
Регистрация: 13.09.2009
Сообщения: 19
Репутация: 10
|
|
Ошибка при считывании
Помогите разобраться с ошибкой. Писал программу для вычисления арифметического выражения...
При попытке высчитать выражение появляется такая ошибка - access violation at address 004514D8 in module 'Project1.exe' . Read of adress 000000
Вот основной модуль
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Unit2, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n:byte;
T:Tpz;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='Операнд';
StringGrid1.Cells[1,0]:='Значение';
Edit1.Clear;
Edit2.Clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i:byte;
Ch:char;
strp:string;
m:extended;
begin
t:=tpz.create;
with t do begin
n:=strtoint(edit3.text);
strp:=Edit1.Text;
for i:=1 to n do
begin
Ch:=StringGrid1.Cells[0,i][1];
T.mszn[ch]:=StrToFloat(StringGrid1.Cells[1,i]);
end;
m:=T.AV(strp);
Edit2.Text:=FloatToStr(m);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var ch:char;
i:integer;
begin
N:=strtoint(Edit3.text);
stringgrid1.rowcount:=N+1;
ch:='a';
for i:=1 to n do begin
stringgrid1.cells[1,i]:=inttostr(random(10)+1);
stringgrid1.cells[0,i]:=ch;
inc(ch);
end;
end;
end.
|