Weird error on arraylist

Discussion in 'Questions (Windows Mobile)' started by ExcludeReality, Mar 31, 2009.

  1. ExcludeReality

    ExcludeReality Active Member Licensed User

    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



    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: Mar 31, 2009
  2. Obelix

    Obelix Member Licensed User


    change the names from NumX to numX and your code works!


  3. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    What does this tell you:

    msgbox (arraylist.indexOf ("sender"))

  4. agraham

    agraham Expert Licensed 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: Mar 31, 2009
  5. ExcludeReality

    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?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice