RAD Studio
ContentsIndex
PreviousUpNext
Iterating Through Strings in a List

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.

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;

 

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 0; i < ListBox1->Items->Count; i++)
    ListBox1->Items->Strings[i] = UpperCase(ListBox1->Items->Strings[i]);
}
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!