Weird error on arraylist

ExcludeReality

Active Member
Licensed User
Hi.
I've been gruding myself over this small bug (?) for a long time. Usually something like this works itself out, But this time it don't seem that way.
It is kind of hard to explain my problem, but I'll give it a shot.

I have 1 arraylist, 1 table, 2 images and 1 button.
When the button is clicked a new image is created at a randon position.
The arraylist will keep track of how many images there is, And the table will keep track of all the images left-property.
When i start the application it looks like this

Arraylist:
Image1
Image2

Table:
175
55

And as i add images, it adds lines to the arraylist and the table.
But i also have a click event, For all of the images.
I assign it after i created a new image using the AddEvent keyword.
So when i click on any image, It goes to a sub.
THIS is where i get an error, the code:

msgbox (table.cell ("Col1",arraylist.indexOf ("sender")))

It makes an msgbox that SHOULD tell me the left property of the image i clicked, But insted it returns -1, Even though i've made many tests to prove that it does exists in the arraylist

I've attached a small example of code, if you didn't fully understand my problem
 
Last edited:

agraham

Expert
Licensed User
Longtime User
The name returned by the Sender keyword will always have been lower-cased so you should add lowercase names to the ArrayList so the IndexOf comparison, which is case-sensitive, works.

arraylist1.Add ("num1")
arraylist1.Add ("num2")
...
arraylist1.Add ("num" & nums)
 
Last edited:

ExcludeReality

Active Member
Licensed User
Thank you very much, The code works now.
No matter how hard you try, In the end it's always a small detail you forgot, huh?
 
Top