1、字符串判定问题:
s1='王刚'
s2='李华、王刚、陈杰、邱少云、王刚、黎明'
怎样才能取出s1在s2中出现的次数以及各次出现的位置?
2、控件问题:
怎样才能利用程序自动生成label控件?并且如果点击该生成的label就可以直接调用ie浏览器,请问如何才能实现?
s1='王刚'
s2='李华、王刚、陈杰、邱少云、王刚、黎明'
怎样才能取出s1在s2中出现的次数以及各次出现的位置?
2、控件问题:
怎样才能利用程序自动生成label控件?并且如果点击该生成的label就可以直接调用ie浏览器,请问如何才能实现?
http://expert.csdn.net/Expert/topic/2835/2835126.xml?temp=6.501406E-02
2:ShellExecute(Handle, 'open', 'IEXPLORE.EXE', nil, '', SW_NORMal);
但是还要在uses中加上shellapi
2:ShellExecute(Handle, 'open', 'IEXPLORE.EXE', nil, '', SW_NORMal);
myLabel.OnClick:=myClickhandle; //在使用前请申明。procedure MyClickHandle(Sender:TObject); //不知还有什么参数,你在一个label的 click事件处理函数去看一下,要写成一样的参数。
begin
ShellExecute(Handle, 'open', 'IEXPLORE.EXE', nil, '', SW_NORMal);
end;
procedure tform1.get(sendger:tobject);
begin
ShellExecute(Handle, 'open', 'IEXPLORE.EXE', nil, '', SW_NORMal);end;
procedure TForm1.Button1Click(Sender: TObject);
var MyLabel:TLabel;
begin
MyLabel:=TLabel.Create(self);
MyLabel.Parent:=form1;
MyLabel.Left :=0;
MyLabel.Top:=0;
MyLabel.width:=20;
MyLabel.Height:=20;
MyLabel.Caption:='ÎÒÊǶ¯Ì¬Éú³ÉµÄ';
mylabel.OnClick:=form1.get; //ÏìÓ¦µÄʼþ
end;
i,appearance:cardinal;
s1,s2:string;
begin
s1='王刚' ;
s2='李华、王刚、陈杰、邱少云、王刚、黎明' ;
i:=pos(s1,s2);
while i>=1 do
begin end;
end;
procedure tform1.get(sendger:tobject);
begin
ShellExecute(Handle, 'open', 'IEXPLORE.EXE', nil, '', SW_NORMal);end;
procedure TForm1.Button1Click(Sender: TObject);
var MyLabel:TLabel;
begin
MyLabel:=TLabel.Create(self);
MyLabel.Parent:=form1;
MyLabel.Left :=0;
MyLabel.Top:=0;
MyLabel.width:=20;
MyLabel.Height:=20;
MyLabel.Caption:='我是动态生成的';
mylabel.OnClick:=form1.get; //响应的事件
end;
i,appearance:cardinal;
s1,s2:string;
begin
s1='王刚' ;
s2='李华、王刚、陈杰、邱少云、王刚、黎明' ;
appearance:=0;
i:=pos(s1,s2);
while i>=1 do
begin
showmessage(s1+'appears in '+s2+' at '+inttostr(i));
inc(appearance);
delete(s2,i,length(s1));
i:=pos(s1,s2);
end;
end;2.uses shellapi;procedure tform1.openie(sender:tobject);//自定义函数。
begin
ShellExecute(Handle, 'open', 'IEXPLORE.EXE', nil, '', SW_show);
end;procedure tform1.create(sender:tobject);
begin
with tlabel.create do
begin
parent:=self;
onclick:=self.openie;
width:=...
caption:=...
end;
end;
var s1,s2:string;
i:integer;
hint:integer;
index:string;
count:integer;begin
s1:='王刚';
s2:='王刚,陈杰、邱少云、王刚、黎明';
index:=s2; //中转 count:=0;
repeat
if count>length(index) then exit;
count:=count+1;
hint:=pos(s1,index);
if hint>0 then
begin
memo1.lines.add('出现位置: '+inttostr(hint));
for i:=0 to length(s1)-1 do
index[hint+i]:='*';
end;
until(false);end;