Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Deleteing from StringList

Posted on 2007-10-10
2
Medium Priority
?
165 Views
Last Modified: 2010-04-05
I have StringList that I need to delete some strings from.  I have a starting index number and and ending index number.  I want to delete those strings and any that are in-between them.  How can I do this?  I tried this:

         for i := iStart to iEnd do
         begin
               SavedDescriptions.Delete(i);
         end;

But I get a ListIndexOutOfBounds error.  

Currently, I'm just changing them all to blank, but I'd really like to have them deleted.

How can I delete the strings?
0
Comment
Question by:light_bulb
2 Comments
 
LVL 5

Accepted Solution

by:
xr1140 earned 2000 total points
ID: 20050909
try this:


         for i := iEnd downto iStart do
         begin
               SavedDescriptions.Delete(i);
         end;


everytime you delete an item your list become shorter.
0
 
LVL 28

Expert Comment

by:2266180
ID: 20051110
or,
 for i := iStart to iEnd do
     SavedDescriptions.Delete(iStart);
:)

also, it is a good idea to do like this
SavedDescriptions.BeginUpdate;
try
 for i := iStart to iEnd do
     SavedDescriptions.Delete(iStart);
finally
  SavedDescriptions.EndUpdate;
end;

in order to speed things up, especially if the number of elements to delete is big.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question