Jump to content

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

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Darkyere

Darkyere

    Newbie

  • Members
  • PipPip
  • 13 posts
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

Edited by WingedPanther, 15 December 2008 - 04:28 AM.
add code tags (the # button)


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I don't see anything obviously wrong with your code, but it looks like it's incomplete (part of a loop?) and without knowing what your form looks like, you may be trying to access a non-existent item!
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Darkyere

Darkyere

    Newbie

  • Members
  • PipPip
  • 13 posts
you are correct, its a part of a code inside a timer and i cut out the parts which had nothing to do whit my problem.

and about u dont see any problem whit my code:

Thats what i dont get either. the first code to multiple images support was the simple taking it from the list start to the end. and it worked fine. now suddenly it work work...

so im just pure and simply lost...

best regards,
darkyere

#4
Darkyere

Darkyere

    Newbie

  • Members
  • PipPip
  • 13 posts
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...
 
begin
  if YourListView.Items.Count > 0 then begin
    if (i +1 < 0) or (i +1 >= YourListView.Items.Count) then begin
      //reset i to 0 or do something else...
 
    end else begin
      Inc(i);
      //get the item...
 
    end;
  end else begin
    //so sorry, no items for you...
 
  end;
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

Edited by Jaan, 16 December 2008 - 11:55 AM.
Please use code tags when you're posting your codes!