本文整理自网络,侵删。
unit Unit2;
interface
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type TForm2 = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form2: TForm2; txt:tstringlist;implementation
{$R *.dfm}
//参数1:要进行补0操作的原始字符串。//参数2:要将该字符串补0后的位数。 //注:该参数是补0后的字符串长度function LeftFillZero(str1:string; count:Integer) :string;var temp : string; len, idex :Integer;
begin len := Length(Trim(str1)); if (len >= count) then begin LeftFillZero:= str1; end else begin for idex := 0 to count-len-1 do begin temp := temp + '0'; end; str1 := temp + str1; LeftFillZero := str1; end
end;
function phonecreate(const sjh: string): string;varphonetxt:tstringlist;i:Integer;begin//delphitop.comphonetxt:=tstringlist.create; for I := 0 to 9999 do begin phonetxt.Add(sjh+LeftFillZero(IntToStr(I),4)); end; Result:=phonetxt.text; phonetxt.free;end;
procedure TForm2.FormCreate(Sender: TObject);beginmemo1.text:=phonecreate('1390347');end;
end.
第二种方法://大悟还俗 DelphiFmx.com(286848376) 提供-------------------------procedure TForm1.FormCreate(Sender: TObject);var Idx: Integer;begin Memo1.Lines.BeginUpdate; for Idx := 0 to 9999 do Memo1.Lines.Add( '1390347'+Format('%.4d', [Idx])); Memo1.Lines.EndUpdate;end;
相关阅读 >>
Delphi xe, xe10, 创建 activeform 和 activex 工程的方法
更多相关阅读请进入《Delphi》频道 >>