Index was out of range error in version 5

Discussion in 'Questions (Windows Mobile)' started by HARRY, May 19, 2007.

  1. HARRY

    HARRY Active Member Licensed User


    My programm used to work on version 4. I found it slow, may be because of SQLite, so I tried version 5.

    Now I get an "Index was out of range error" on the call of a sub named Show1. If I make comment of this call then message is given on the next line Show2.
    This error occurs in a sub "Table1_SelectionChanged (ColName, Row)".

    At the start of the test I have struggled somewhat with suddenly missing ')' 's and inserted extra '.' 's.

    Any idea?

  2. Erel

    Erel Administrator Staff Member Licensed User

    The missing ')' were missing before, Basic4ppc just didn't warn you about them.
    Can you post some of your code?
    You can also send it to me if you like.
  3. HARRY

    HARRY Active Member Licensed User


    Some code:

    Sub Show1
    bmpsrc1.New1(PhotoPath & Photo1)
    End sub

    Sub Show2
    bmpsrc2.New1(PhotoPath & Photo2)
    End sub

    Sub Table1_SelectionChanged (ColName, Row)
    If ShowMode=true then
    Photo1=Table1.Cell("Photo1",Row)& ".bmp"
    Photo2=Table1.Cell("Photo2",Row)& ".bmp"
    Photo3=Table1.Cell("Photo3",Row)& ".bmp"
    If Photo1 = ".bmp" Then
    end if

    If Photo2 = ".bmp" Then
    end if

    If Photo3 = ".bmp" Then
    end if
    If Ignore=false then
    TextBox1.Text= Table1.Cell("Photo1",Row)
    TextBox2.Text= Table1.Cell("Photo2",Row)
    TextBox3.Text= Table1.Cell("Photo3",Row)
    end if
    end if

    The underlined line causes the problem.

    Photo1, Photo2 and Photo3 are declared globals.

    If you need I can also send you the complete application with the data base and some other stuff.

  4. Erel

    Erel Administrator Staff Member Licensed User

    Please send me the complete application.
  5. HARRY

    HARRY Active Member Licensed User


    Attached the application, the data base and a few images.

    Create a map named POI_PHOTOS in the path indicated in the program; put the two Aimée Porcher images and the dummy2 image in that map.

    Start the program and click on the name Aimee Porcher in the campings table. Then the error should occur.

  6. Erel

    Erel Administrator Staff Member Licensed User

    I highly recommend you to use the Check unassigned variables option.
    When I've tried to compile your code it showed an error that Show1 is an unused variable.
    For some reason it didn't recognize it as a Sub.
    After a deeper inspection I've found out that there was a strange character (instead of space) in the declaration of Show1 / 2 / 3.
    Just change this character to space (between the Sub to Show1/2/3) and it should work properly.
  7. HARRY

    HARRY Active Member Licensed User


    Thanks again for your help. Three backspaces and spaces on the keyboard were enough to solve the problem. In fact, I have done it too fast. I had better investigate myself those strange characters; may be that I could have found the origin.

    What surprises me is that those strange characters are not printed. In a VB program I wrote myself unprintable characters are 'printed' as black squares.
    I do not know whether that is a function of VB or of Windows.

    If they were printed, I could possibly have solved the problem without bothering you.

    Anyhow, thanks.

  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