5,388
社区成员
发帖
与我相关
我的任务
分享
uses StrUtils;
RightStr(str1,5);
function GetStr(SS,S:String):string;
var i:integer;
begin
GetStr:='';
For i:=Length(SS) downto 1 do
begin
if SS[i]=S then
begin
GetStr:=Copy(SS,i+1,Length(SS)-i);
exit;
end;
end;
end;
加一句exit,更完善。function GetStr(SS,S:String):string;
var i:integer;
begin
GetStr:='';
For i:=Length(SS) downto 1 do
begin
if SS[i]=S then
begin
GetStr:=Copy(SS,i+1,Length(SS)-i);
ecit;
end;
end;
end;
加一句exit,更完善。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetStr(SS,S:String):string;
var i:integer;
S1:string;
begin
GetStr:='';
For i:=Length(SS) downto 1 do
begin
if SS[i]=S then
GetStr:=Copy(SS,i+1,Length(SS)-i);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit3.Text:=GetStr(Edit1.Text,Edit2.Text);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
edit1.Text:='AC12(021ADE';
edit2.Text:='(';
edit3.Text:='';
end;
end.
function GetStr(SS,S:String):string;
就是为你做的函数。仅供参考。