943,549 Members | Top Members by Rank

Ad:
Dec 15th, 2008
0

Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in

Expand Post »
here i go whit a new problem and yet the same... i think.
on one of the forums i posted my last question in (im lost) the answer was that i could set i to be 0 from start in form load procedure. i did and it worked for a time. now it comes whit this error

Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in module 'security screensaver.exe' read of adress 00000020'.

if i = Listview1.Items.Count -1 then
begin
if checkbox1.Checked = true then
begin
i := 0;
item := listview1.Items[i];
form2.image1.Picture.LoadFromFile(item.Caption);
end
else
begin
timersec.Enabled := false;
end;
end
else
begin
if checkbox2.Checked = true then {if randomize is true}
begin
end
else
begin
i := i + 1;
item := listview1.Items[i];
form2.image1.Picture.LoadFromFile(item.Caption); {this is where the error occurs}

form2.label8.Caption := 'Size of image: ' + inttostr(getfilesize(item.Caption) div 1024) + ' KB';
form2.Label7.Caption := item.Caption;

end;
end;

i hope someone now the answer cause im simply lost.

first it work, then not and i need to set i to be 0 from the start, then it works... and now suddenly a new error pops up..
i really cant understand the problem.

best regards,
Darkyere
Reputation Points: 10
Solved Threads: 0
Newbie Poster
darkyere is offline Offline
17 posts
since Nov 2008
Dec 15th, 2008
0

Re: Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in

Once again, debug it, follow what "i" is, and see what item you're referencing. Once again, no code tags, so im not even going to bother reading it this time.

You dont seem to do any validation to check wether i is a valid item or not
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Dec 16th, 2008
0

Re: Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in

Pascal and Delphi Syntax (Toggle Plain Text)
  1. if i = Listview1.Items.Count -1 then
  2. begin
  3. if checkbox1.Checked = true then
  4. begin
  5. i := 0;
  6. item := listview1.Items[i];
  7. form2.image1.Picture.LoadFromFile(item.Caption);
  8. end
  9. else
  10. begin
  11. timersec.Enabled := false;
  12. end;
  13. end
  14. else
  15. begin
  16. if checkbox2.Checked = true then {if randomize is true}
  17. begin
  18. end
  19. else
  20. begin
  21. i := i + 1;
  22. item := listview1.Items[i];
  23. form2.image1.Picture.LoadFromFile(item.Caption); {this is where the error occurs}
  24.  
  25. form2.label8.Caption := 'Size of image: ' + inttostr(getfilesize(item.Caption) div 1024) + ' KB';
  26. form2.Label7.Caption := item.Caption;
  27.  
  28. end;
  29. end;

im sorry that i forget to put the code tags on. as u mention this is enforently not the first time.

im rather new at programming and am still learning.

something i dont now for an instance. how do i debug it. ive searched all menus in delphi 2009 after the debug option but i cant seem to find it.

and how do i validate an item to check if tis an valid item?

im sorry that im so much noob i need to get everything in with a spoon. but i hope u understand, and if u do i thank you for your time and understanding.

best regards,
Darkyere
Reputation Points: 10
Solved Threads: 0
Newbie Poster
darkyere is offline Offline
17 posts
since Nov 2008
Dec 16th, 2008
0

Re: Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in

on one of the forums i posted a person created these wonderful line of code


You need to check the value of i and your items.count...


Pascal and Delphi Syntax (Toggle Plain Text)
  1. begin
  2. if YourListView.Items.Count > 0 then begin
  3. if (i +1 < 0) or (i +1 >= YourListView.Items.Count) then begin
  4. //reset i to 0 or do something else...
  5.  
  6. end else begin
  7. Inc(i);
  8. //get the item...
  9.  
  10. end;
  11. end else begin
  12. //so sorry, no items for you...
  13.  
  14. end;
  15. end;


"There is a theory which states that if ever anybody discovers
exactly what the Universe is for and why it is here, it will
instantly disappear and be replaced by something even more
bizarre and inexplicable. There is another theory which states
that this has already happened."
-- Douglas Adams

Chris

Best regards,
Darkyere
Reputation Points: 10
Solved Threads: 0
Newbie Poster
darkyere is offline Offline
17 posts
since Nov 2008
Dec 17th, 2008
0

Re: Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in

to debug it, I guess you havent found the inserting of break points and stepping through code (or just plain stepping through it from the beginning)
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Dec 18th, 2008
0

Re: Exception class EAccesViolation with message 'Acces violation at adress 004bb914 in

Darkyere,

Check out this site:

http://blogs.codegear.com/nickhodges/2006/08/15/26687

These demonstration files are excellent tutorials for beginners on many features of Delphi including using the debugger. Since your new, it would pay to spend a day going through all of them.
Last edited by jsosnowski; Dec 18th, 2008 at 9:59 am.
Reputation Points: 11
Solved Threads: 11
Junior Poster in Training
jsosnowski is offline Offline
68 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: TXMLDocument --> TListBox (Easy!)
Next Thread in Pascal and Delphi Forum Timeline: Pascal Help!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC