How to extract text line by line from TMemo?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jewel87
    New Member
    • Jan 2007
    • 62

    How to extract text line by line from TMemo?

    Hi everyone,

    I need to check for a substring in each line of a TMemo, how can I get each line separately?
    I'm using this method now:
    Code:
     int found;
            for (int i=1; i<MemoLines; i++)
            {
                    String str = ShoppingBasketMemo->Lines->GetText();
                    found = str.Pos(ProductNameForSearch);
                    if (found!=0)
                            ShoppingBasketMemo->Lines->Delete(i);
    But it is giving me all lines together into str, i can't separate them out.
    Can't also find any function to do that. Does anyone know this?
  • Savage
    Recognized Expert Top Contributor
    • Feb 2007
    • 1759

    #2
    Originally posted by jewel87
    Hi everyone,

    I need to check for a substring in each line of a TMemo, how can I get each line separately?
    I'm using this method now:
    Code:
     int found;
            for (int i=1; i<MemoLines; i++)
            {
                    String str = ShoppingBasketMemo->Lines->GetText();
                    found = str.Pos(ProductNameForSearch);
                    if (found!=0)
                            ShoppingBasketMemo->Lines->Delete(i);
    But it is giving me all lines together into str, i can't separate them out.
    Can't also find any function to do that. Does anyone know this?
    This is C++ builder,right?
    If so,I believe that Lines are array of AnsiStrings,whi ch means that by specifying it's index you could get ith line from the control.

    Savage

    Comment

    Working...