Project Project1.exe raised exception class EAccessViolation with message
На моментв ызова 2 формы кикает и пишет "Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 00456B02 in module 'Project1.exe'. Read of address 000002F4"
Вчера было все нормально,потом что то дописал и походу не так,вроде все снес в коменты что добавлял,но все равно вылетает
Форма 1
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls,FileCtrl, OleCtrls, SHDocVw,XPMan;
type
TForm1 = class(TForm)
mmo1: TMemo;
mm1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
Button1: TButton;
lst1: TListBox;
cbb1: TComboBox;
RadioGroup1: TRadioGroup;
PageControl1: TPageControl;
PopupMenu1: TPopupMenu;
N3: TMenuItem;
TabSheet1: TTabSheet;
WebBrowser1: TWebBrowser;
N4: TMenuItem;
a1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure cbb1Change(Sender: TObject);
procedure lst1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure lst1DblClick(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure a1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Put,ServerDir,Choyse,sel,sel2:string;
kol:integer;
btn:TButton;
implementation
uses
Unit2;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
ServerAdress:System.text;
begin
kol:=0;
Put:='C:\Ñåòåâîå ïîñîáèå\ServerAdress.txt';
CreateDir('C:\Ñåòåâîå ïîñîáèå');
Mmo1.Lines.LoadFromFile(Put); //èñïîëüçîâàíèå äèðåêòîðèè áàçû
ServerDir:=Mmo1.Lines[0];
Mmo1.Clear;
ServerDir:=ServerDir+'\';
Button1.Click;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
papki:TSearchRec;
begin
cbb1.Clear;
if FindFirst(ServerDir+'*',faDirectory,papki) =0 then //çàãðóçêà âñåõ ïàïîê â Cbb1
begin
repeat
if (papki.Attr and faDirectory)=faDirectory then
begin
if (papki.Name<>'.') and (papki.Name<>'..') then
begin
cbb1.Items.Add(papki.Name);
end;
end;
until FindNext(papki) <> 0;
FindClose(papki);
end;
{if cbb1.Items.Count=1
then cbb1.ItemIndex:=0;}
end;
procedure TForm1.cbb1Change(Sender: TObject);
var
papki:TSearchRec;
begin
RadioGroup1.Items.Clear;
sel:=cbb1.Items[cbb1.itemindex]; //âûáðàíûé èòåì cbb1-ãî
lst1.Clear;
if FindFirst(ServerDir+sel+'\*',faDirectory,papki) =0 then //çàãðóçêà âñåõ ïàïîê â ÐàäèîÃðóïïó
begin
repeat
if (papki.Attr and faDirectory)=faDirectory then
begin
if (papki.Name<>'.') and (papki.Name<>'..') and (papki.Name<>'Òåñòû') then
begin
RadioGroup1.Items.Add(papki.Name);
end;
end;
until FindNext(papki) <> 0;
FindClose(papki);
end;
{if RadioGroup1.Items.Count=1
then RadioGroup1.ItemIndex:=0; }
end;
procedure TForm1.lst1Click(Sender: TObject);
Begin
PageControl1.Pages[0].Caption:=lst1.Items[lst1.itemindex];
WebBrowser1.Navigate(ServerDir+sel+'\'+sel2+'\'+lst1.Items[lst1.itemindex]+'.mht');//ïðîãðóçêà â áðàóçåð
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
var
sr:TSearchRec;
format:string;
begin
sel2:=RadioGroup1.Items[RadioGroup1.ItemIndex]; //âûáðàíûé èòåì Ðàäèîãðóïïû
lst1.Clear;
if FindFirst(ServerDir+sel+'\'+sel2+'\*.mht',faAnyFile,sr) = 0 then //Ïîèñê ôàéëîâ
begin
repeat
begin
format:=sr.Name;
Delete(format,Pos('.mht',format),Length(format));//Îòðåçàåì ôîðìàò
lst1.Items.Add(format); //âûãðóçêà â ËñòÁ1
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
procedure TForm1.lst1DblClick(Sender: TObject);
var
NewPage:TTabSheet;
Newbr:TWebBrowser;
cap:string;
begin
if Kol<10 then
begin
NewPage:=TTabSheet.Create(Self); //Ñîçäàíèå âêëàäêè
NewPage.PageControl:=PageControl1;
cap:=Lst1.Items[Lst1.ItemIndex];
Delete(cap,9,Length(cap));
NewPage.Caption:=cap;
NewPage.tag:=kol;
PageControl1.ActivePage:=NewPage;
Newbr:=TWebBrowser.Create(NewPage);
TWinControl(Newbr).Parent:=NewPage;
Newbr.Align:=alClient;
kol:=kol+1;
Newbr.Navigate(ServerDir+sel+'\'+sel2+'\'+lst1.Items[lst1.itemindex]+'.mht');//ïðîãðóçêà â áðàóçåð
end;
end;
procedure TForm1.a1Click(Sender: TObject);
begin
Form2.Show;
end;
end.
Фома 2
Код:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
Panel1: TPanel;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
ListBox1: TListBox;
RadioGroup1: TRadioGroup;
ComboBox2: TComboBox;
Label4: TLabel;
Button2: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
group,fio,pred,tst:string;
Nach,Kon,ver,never,kolvop:integer;
implementation
uses
Unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
i:Integer;
begin
if Edit1.Text<>'' then
begin
if Edit2.Text<>'' then
begin
if ComboBox2.ItemIndex=0 then
begin
fio:=Edit1.Text; //Çàïèñü äàííûõ
group:=Edit2.Text;
pred:=ComboBox2.Items[ComboBox2.ItemIndex];
Panel1.Visible:=false; //ñêðûòèå íà÷àëüíîãî îêíà
Form2.Caption:='Òåìà:'+pred;
Memo1.Lines.LoadFromFile(ServerDir+ComboBox1.Items[ComboBox1.Itemindex]+'\Òåñòû\'+
pred+'.txt'); //çàãðóçêà â ìåìî1
for i:=0 to Memo1.Lines.Count -1 do //öèêë ñîçäàíèå âîïðîñîâ
begin
if Pos('¹',Memo1.Lines[i])<>0 then
begin
ListBox1.Items.Add('Âîïðîñ '+inttostr(Listbox1.Items.Count+1));
end;
if i=Memo1.Lines.Count -1 then
begin
Memo1.Lines.Add('¹'+inttostr(Listbox1.Items.Count+1)); //Äîáàâëåíèå ïóñòîãî âîïðîñà ÷òî áû íå áàãàëñÿ ïîä÷åò
end;
end; //ñîçäàëè âîïðîñû
{kolvop:=ListBox1.Items.Count;
label7.Caption:='Îñòàëîñü:'+inttostr(kolvop)+' âïîðîñîâ'; }
end
else
begin
ShowMessage('Óêàæèòå òåìó');
end;
end
else
begin
ShowMessage('Óêàæèòå ãðóïïó');
end;
end
else
begin
ShowMessage('Çàïîëíèòå ïîëå Ô.È.Î.');
end;
end;
procedure TForm2.FormActivate(Sender: TObject);
var
papki:TSearchRec;
begin
if FindFirst(ServerDir+'*',faDirectory,papki) =0 then //çàãðóçêà âñåõ ïðåäìåòîâ â Cbb1
begin
repeat
if (papki.Attr and faDirectory)=faDirectory then
begin
if (papki.Name<>'.') and (papki.Name<>'..') then
begin
ComboBox1.Items.Add(papki.Name);
end;
end;
until FindNext(papki) <> 0;
FindClose(papki);
end;
{if ComboBox1.Items.Count=1
then ComboBox1.ItemIndex:=0;}
end;
procedure TForm2.ComboBox1Change(Sender: TObject);
var
tema:TSearchRec;
begin //çàãðóçêà òåñòîâ â ñáá2
ComboBox2.Items.Clear;
if FindFirst(ServerDir+ComboBox1.Items[ComboBox1.Itemindex]+'\Òåñòû\*.txt',faAnyFile,tema) =0 then
begin
repeat
if (tema.Name<>'.') and (tema.Name<>'..') then
begin
Delete(tema.Name,Pos('.txt',tema.Name),Length(tema.Name));
ComboBox2.Items.Add(tema.Name);
end;
until FindNext(tema) <> 0;
FindClose(tema);
end;
{ if ComboBox2.Items.Count=1
then ComboBox2.ItemIndex:=0;}
end;
procedure TForm2.ListBox1Click(Sender: TObject);
var
vopN,vopk,vr,vb:string;
i,j,z:integer;
begin
Memo2.Clear;
RadioGroup1.Items.Clear;
vopN:='¹'+inttostr(ListBox1.ItemIndex+1);
vopk:='¹'+inttostr(ListBox1.ItemIndex+2);
for i:=0 to memo1.Lines.count-1 do
begin
if Pos(vopN,Memo1.Lines[i])<>0 then //íà÷àëî âûäåëåííîãî âîïðîñà
begin
Nach:=i;
end;
if Pos(vopk,Memo1.Lines[i])<>0 then //ñëåäóþùèé âîïðîñ
begin
kon:=i;
end;
end;
for j:=Nach to Kon-1 do
begin
if Pos('@',memo1.Lines[j])<>0 then //ïðîãðóçêà âàðèàíòîâ îòâåòà â ðã1
begin
vr:=memo1.Lines[j];
Delete(vr,1,1);
RadioGroup1.Items.Add(vr);
end
else
begin
Memo2.Lines.Add(Memo1.Lines[j]); //çàãðóçêà âîïðîñà â ìåìî2
end;
end;
for z:=0 to RadioGroup1.Items.Count-1 do
begin
if Pos('`',RadioGroup1.Items[z])<>0 then //âûðåçàåì èíäèêàòîð ïðàâåëüíî îòâåòà
begin
vb:= RadioGroup1.Items[z];
Delete(vb,Pos('`',vb),1);
RadioGroup1.Items[z]:=vb;
end;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
otv:string;
begin //Ïðîöåäó ïîä÷åòà è ñâåðêè îòâåòà
kolvop:=kolvop-1;//ïîä÷åò îñòàâøèõñÿ âîïðîñîâ
otv:=RadioGroup1.Items[RadioGroup1.ItemIndex];
otv:='@'+otv+'`';
if Memo1.Lines[Nach+memo2.Lines.Count+RadioGroup1.ItemIndex]=otv
then Ver:=ver+1
else Never:=never+1;
label6.Caption:='Íåâåðíî:'+inttostr(never);
label5.Caption:='Âåðíî:'+inttostr(ver);
label7.Caption:='Îñòàëîñü:'+inttostr(kolvop)+' âïîðîñîâ';
end;
end.
|