delphi 实现生成手机号段


本文整理自网络,侵删。

 
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;
var
phonetxt:tstringlist;
i:Integer;
begin//delphitop.com
phonetxt:=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);
begin
memo1.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 tbytedynarray转化为string

Delphi 一个绘制虚线的非常规函数(常规方法,打印机上绘制不出虚线)

Delphi winapi: getmodulefilename、getmodulehandle

Delphi 四舍五入取整函数

Delphi 关闭指定窗口标题的窗口

Delphi xe10.1 引用计数

Delphi 修改exe应用程序图标

Delphi gettempdirectory 获取临时文件夹路径

Delphi xe8 无法进入android的调试状态

Delphi如何在一个窗体中嵌入另一个窗体

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...