unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{分割字符串的函数, 其实是个过程}
procedure Split(const str: string; const c: Char; var List: TStrings);
begin
List.Clear;
List.Delimiter := c;
List.DelimitedText := str;
end;
{调用测试}
procedure TForm1.Button1Click(Sender: TObject);
var
List: TStrings;
s: string;
c: Char;
begin
s := ‘aaa;bbb;ccc;ddd‘;
c := ‘;‘;
List := TStringList.Create;
Split(s,c,List);
ShowMessage(List[1]); {bbb}
List.Free;
end;
end.
//DEMO下载:http://files.cnblogs.com/files/FanYs/demo.rar
时间: 2024-10-12 22:45:03