Deleteing from StringList

Posted on 2007-10-10
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

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?
Question by:light_bulb
    LVL 5

    Accepted Solution

    try this:

             for i := iEnd downto iStart do

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

    Expert Comment

     for i := iStart to iEnd do

    also, it is a good idea to do like this
     for i := iStart to iEnd do

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

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    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 gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now