RAD Studio |  |

Iterating Through Strings in a List
See Also
Collapse All

To iterate through the strings in a list, use a for loop that runs from zero to Count –1.

The following example converts each string in a list box to uppercase characters.

Copy Code

    procedure TForm1.Button1Click(Sender: TObject);var  Index: Integer;
    begin
      for Index := 0 to ListBox1.Items.Count - 1 do     ListBox1.Items[Index] := UpperCase(ListBox1.Items[Index]);
    end;

Copy Code

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      for (int i = 0; i < ListBox1->Items->Count; i++)
        ListBox1->Items->Strings[i] = UpperCase(ListBox1->Items->Strings[i]);
    }

See Also

Manipulating Strings in a List

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!