Sometimes we need to know whether a string is contained in a stringlist. This post will discuss about how to find a string inside the stringlist. If it is found, it will return true, otherwise false. Here is the sample code :
var MyList:TStringlist;
Found:Boolean;
begin
if MyList.IndexOf('item name') = -1 then
Found := false
else
Found := true;
end;
function TfrmForm.IsItemFoundInList(AslList: TStringList; AsText: String): Boolean;
ReplyDeletebegin
Result := AsList.IndexOf(AsText) > -1;
end;