I'm starting to distill myself...

Discussion in 'Questions (Windows Mobile)' started by Cableguy, Sep 14, 2007.

  1. Cableguy

    Cableguy Expert Licensed User

    this is driving me KKRRAZY!!!:sign0137:

    I have started a new game project, in wich to keep control of things, I am defining the row/col count of a table control, according to user difficulty selection....

    I start by using a for...next cycle to delete the existing rows/cols of the table and then add row/col according to user selection...so far so good, well not so...If there is no rows or cols in the table before user selection (i.e: when he app is first started) it works fine, but if there is already a number of rows/cols I keep getting an "index canot be negative" sort of error...

    I added msgboxs to each of my for next loops and it seems ok....
    Im first deleting rows and then collumns, shoul I invert?
    Both counts start from "0" Right?
     
  2. specci48

    specci48 Well-Known Member Licensed User

    Hi Cableguy,

    Yes, you're right!

    To solve your problem, I think some posted code would be nice because your description sounds good so we might take a look at your current solution to find out the problem...


    specci48
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    I'll give my guess.
    You're using a For loop to delete the rows:
    For i = 0 to Table1.RowCount
    'Remove row i
    Next

    That is a wrong solution! As you are removing each row, row #i becomes row #i-1...
    You should do something like:
    For i = 0 To Table1.RowCount
    'Remove Row 0
    Next

    BTW, why don't you use Table1.Clear?
     
  4. moharj

    moharj Member Licensed User

    delete col and rows

    you can go in the reverse order of the for next
    deleting the last one all the way down....:)
     
  5. Cableguy

    Cableguy Expert Licensed User

    Right to the point as usual, Erel.

    That was exactly what I was trying...

    I also tried that aproach and it error even more often....

    The clear property has some how iluded me as I started exactly by seaching for that aproach instead of "manually" delete the rows/cols...

    And they say I'm an Expert, yah, right...:sign0161:
     
Loading...