第一问函数:
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetStrPos(SubStr,SourStr:string;xth:Integer):Integer;
/*substr:查找字串,sourstr主串,xth第x个字串*/
end;
-------------------------------------------------------------------------
function TForm1.GetStrPos(SubStr,SourStr: string;xth:Integer): Integer;
var
Count,i : Integer;
begin
Count := 0;
Result :=0;
for i:=1 to Length(SourStr) do
begin
if Copy(SourStr,i,Length(SubStr))=SubStr then
begin
Inc(Count);
if Count= xth then
begin
Result := i;
Exit;
end;
end;
end;
end;