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

    Erel,

    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?

    Harry
     
  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

    Erel,

    Some code:

    Sub Show1
    bmpsrc1.Dispose
    AddObject("bmpsrc1","Bitmap")
    bmpsrc1.New1(PhotoPath & Photo1)
    drawer1.DrawImage1(bmpsrc1.Value,rectsrc1.Value,rectdes1.Value,true)
    drawer1.Refresh2(rectdes1.Value)
    End sub

    Sub Show2
    bmpsrc2.Dispose
    AddObject("bmpsrc2","Bitmap")
    bmpsrc2.New1(PhotoPath & Photo2)
    drawer2.DrawImage1(bmpsrc2.Value,rectsrc2.Value,rectdes2.Value,true)
    drawer2.Refresh2(rectdes2.Value)
    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
    Photo1=dummy
    end if

    If Photo2 = ".bmp" Then
    Photo2=dummy
    end if

    If Photo3 = ".bmp" Then
    Photo3=dummy
    end if
    Show1
    Show2
    Show3
    else
    If Ignore=false then
    TextBox1.Text= Table1.Cell("Photo1",Row)
    TextBox2.Text= Table1.Cell("Photo2",Row)
    TextBox3.Text= Table1.Cell("Photo3",Row)
    end if
    ResetColors
    PhotoSeq=0
    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.

    Harry
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Please send me the complete application.
     
  5. HARRY

    HARRY Active Member Licensed User

    Erel,

    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.

    Harry
     
  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

    Erel,

    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.


    Harry
     
Loading...