function StringIndex(const SearchString: string; StrList: array of string): Integer;
var
I: Integer;
begin
Result:= -1;
for I:= 0 to High(StrList) do
if CompareText(SearchString, StrList[I]) = 0 then
begin
Result:= I;
Break;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
case StringIndex('A', ['A', 'B', 'C']) of
-1: ShowMessage('Not in the list');
0: ShowMessage('A');
1: ShowMessage('B');
2: ShowMessage('C');
end;
end;
From www.delphi3000.com
2004年10月31日 20:39