窗体资源代码如下:
object Form1: TForm1
Left = 192
Top = 112
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object lbl1: TLabel
Left = 104
Top = 24
Width = 16
Height = 13
Caption = 'lbl1'
end
object btn1: TButton
Left = 104
Top = 136
Width = 75
Height = 25
Caption = 'btn1'
TabOrder = 0
OnClick = btn1Click
end
object edt1: TEdit
Left = 280
Top = 80
Width = 121
Height = 21
TabOrder = 1
Text = '111>>>222>>>333>>>'
end
end
程序单元代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
lbl1: TLabel;
edt1: TEdit;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
function GetList(const aStr: String
const aSep: String): TStringList;
var
strTmp: String;
intPos: Integer;
begin
Result := TStringList.Create;
strTmp := aStr;
with Result do
begin
while Length(strTmp) > 1 do
begin
intPos := Pos(aSep,strTmp);
Add(Copy(strTmp,1,intPos - 1));
strTmp := Copy(strTmp,intPos + Length(aSep),Length(strTmp));
end;
end;
end;
var
I: Integer;
astrlistTmp: TStringList;
begin
//astrlistTmp := TStringList.Create;
astrlistTmp := GetList(edt1.Text,'>>>');
for I := 0 to astrlistTmp.Count - 1 do
ShowMessage(astrlistTmp.Strings);
end;
end.