Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 04.11.2007, 17:09   #1
Ravnica
 
Регистрация: 04.11.2007
Сообщений: 3
По умолчанию Ошибка: "EAccessViolation with message..."

Вот написал програму-тест.Вопросы и ответы считует с текст файла.При окончании отвечать на все вопросы выскакует ошибка "Project Survey.exe raised exception class EAccessViolation with message 'Access violation at address 00404832 in module 'Survey.exe'.Read of address 00740065'.Process stopped."

Цитата:
unit SurveyUnit;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, jpeg;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
OpenDialog1: TOpenDialog;
Label1: TLabel;
Image1: TImage;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Button1: TButton;
procedure Exit1Click(Sender: TObject);
procedure File1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
fname: String;
questions: array [1..5] of array [1..10] of String;
orderq: array [1..5] of integer;
myfile: TextFile;
i,j, countq, curq, bal: Integer;


implementation

{$R *.dfm}
procedure ShowQuestion (NumQuest: Integer);
begin
try
Form1.Image1.Visible:=false;
Form1.Image1.Picture.LoadFromFile(q uestions[NumQuest,2]);
Form1.Image1.Visible:=true;
except

end;
Form1.Label1.Caption:=questions[NumQuest,1];
Form1.RadioButton1.Caption:=questio ns[NumQuest,3];
Form1.RadioButton1.Checked:=True;
Form1.RadioButton2.Caption:=questio ns[NumQuest,4];
Form1.RadioButton3.Caption:=questio ns[NumQuest,5];
Form1.RadioButton4.Caption:=questio ns[NumQuest,6];
end;

procedure GetOrder;
var curv,iq,jq: integer;
bad: boolean;
begin
for iq:=1 to 5 do
begin
orderq[iq]:=0;
end;
for iq:=1 to 5 do
begin
bad:=true;
while bad do
begin
Randomize;
curv:=Random(6);
bad:=false;
for jq:=1 to 5 do
begin
if orderq[jq]=curv then bad:=true;
end;
if not bad then orderq[iq]:=curv;
end;
end;
end;

procedure TForm1.Exit1Click(Sender: TObject);
begin
Form1.Close;
end;

procedure TForm1.File1Click(Sender: TObject);
var
testread: string;
begin
if OpenDialog1.Execute then
begin
bal:=0;
fname:=OpenDialog1.FileName;
AssignFile(myFile, fname);
Reset(myFile);
countq:=0;
while not Eof(myFile) do
begin
ReadLn(myFile, testread);
countq:=countq+1;
end;
if countq>49 then
begin
Reset(myFile);
for i:=1 to 5 do
for j:=1 to 10 do
begin
Readln(myFile,questions[i,j]);
end;
CloseFile(myFile);
curq:=1;
Button1.Enabled:=true;
GetOrder;
ShowQuestion(orderq[curq]);
end
else
begin

end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
try
if RadioButton1.Checked=true then bal:=bal+StrToInt(questions[curq,7]);
if RadioButton2.Checked=true then bal:=bal+StrToInt(questions[curq,8]);
if RadioButton3.Checked=true then bal:=bal+StrToInt(questions[curq,9]);
if RadioButton4.Checked=true then bal:=bal+StrToInt(questions[curq,10]);
except

end;
if curq<6 then
begin
curq:=curq+1;
ShowQuestion(orderq[curq]);
end;
if curq=6 then
begin
if bal=5 then MessageDlg('Плохо. Ваша оценка ' + IntToStr(bal),mtInformation,[mbOk], 0);
if bal=10 then MessageDlg('Нормально. Ваша оценка ' + IntToStr(bal),mtInformation,[mbOk], 0);
if bal=15 then MessageDlg('Хорошо. Ваша оценка ' +IntToStr(bal),mtInformation,[mbOk], 0);
if bal=20 then MessageDlg('Отлично. Ваша оценка ' + IntToStr(bal),mtInformation,[mbOk], 0);
if bal=25 then MessageDlg('ВЕЛИКОЛЕПНО!!! Ваша оценка ' + IntToStr(bal),mtInformation,[mbOk], 0);
Close;
end;
end;

end.
Ошибка на месте Form1.Image1.Visible:=true; Помогите разобраться и найти ошибку.
Ravnica вне форума Ответить с цитированием
Старый 04.11.2007, 17:29   #2
Alex21
With best regards
Участник клуба
 
Регистрация: 20.04.2007
Сообщений: 1,448
По умолчанию

Ошибка на этой строке:
Цитата:
Form1.Image1.Picture.LoadFromFile(q uestions[NumQuest,2]);
Уверены, что массивы заполнены правильно?
Alex21 вне форума Ответить с цитированием
Старый 04.11.2007, 17:43   #3
Ravnica
 
Регистрация: 04.11.2007
Сообщений: 3
По умолчанию

Хм...С десяток раз уже проверял,если покажете где ошибка буду благодарен.
Ravnica вне форума Ответить с цитированием
Старый 04.11.2007, 18:13   #4
zetrix
Delphi/C++/C#
Участник клуба
 
Аватар для zetrix
 
Регистрация: 29.10.2006
Сообщений: 1,972
По умолчанию

Отладку делать не стал, но этот еррор возникает при попытке обратиться м... например к 5 элементу массива a: array [1..4], т.е. к элементу выходящему за пределы массива.
zetrix вне форума Ответить с цитированием
Старый 04.11.2007, 20:46   #5
Ravnica
 
Регистрация: 04.11.2007
Сообщений: 3
По умолчанию

попробывал поменять в array [1..5] что-то большое чем 5,но пишет тоже самое.Найдите пожалуйста ошибку
Ravnica вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Ошибка при использовании OlePropertyGet("Documents").OleProcedure("Add") в C++ Builder AleksP C++ Builder 7 11.04.2009 13:06
"Ошибка приложения" при запуске мидлета hotman Общие вопросы по Java, Java SE, Kotlin 0 04.09.2008 15:16
если пользователь наберет какой-то другой символ не "y" или "n" и нажмет enter, программа проигнорирует skobets Общие вопросы C/C++ 2 03.06.2008 06:51
Excel файл открывается не "до конца" (странички "не показываются" только серое поле) Dorvir Microsoft Office Excel 2 28.03.2008 10:03
Создаю диаграмму "Bar". Подскажите как убрать растояние между "столбами" MAcK Компоненты Delphi 11 24.10.2007 10:49