Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Delete rows in table

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-29-2007, 04:33 PM
Newbie
 
Join Date: Apr 2007
Posts: 2
Default Delete rows in table

Hi.
I want to search a table for a value and when the value is found, to delete the row .
I tried the code below , but I got index error
-------
f = table1.RowCount -1
for j = 0 to f
If table1.Cell("Car",j) = 5 Then
table1.RemoveRow(j)
f = f - 1
End If
next
-------
Is there a beter way to do it ?

Thanks
Sefi.
Reply With Quote
  #2 (permalink)  
Old 04-29-2007, 05:36 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

If the database is large then you could use TableSort to first sort the rows and then do a more optimized search (binary search).
The error you are seeing is caused due to the fact that the limit in the For loop is only calculated at the beginning (to save the calculation each loop).
You can change your code to:
Code:
j = 0
Do While j < Table1.RowCount
 
If table1.Cell("Car",j) = 5 Then
   table1.RemoveRow(j) 
'Do not advance j here.
 else
   j = j + 
1
 
end if
Loop
Reply With Quote
  #3 (permalink)  
Old 04-30-2007, 07:05 PM
Newbie
 
Join Date: Apr 2007
Posts: 2
Default Thanks

Thank you .
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change rows position in a table francisco cobos Questions (Windows Mobile) 3 10-27-2008 07:47 PM
read and delete sms...how? Byak@ Questions (Windows Mobile) 1 10-12-2008 06:42 PM
Delete a row in a table and simultaneously delete it in the database gonzamax Questions (Windows Mobile) 2 12-25-2007 01:23 PM
Delete keypress emaster Questions (Windows Mobile) 2 12-04-2007 06:15 AM
Delete Control and Delete Form Items alfcen Basic4ppc Wishlist 3 10-05-2007 12:09 PM


All times are GMT. The time now is 06:38 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0