Delphi 获取随机字符串的方法 GetRandomString


本文整理自网络,侵删。

 
function SuiJiString(const AWeiShu: Integer): string;
const
  SourceStr: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var
  MyRep: string;
  I: Integer;
begin
  Randomize;
  for I := 1 to AWeiShu do
  begin
    //这里只所以必须加1,是因为SourceStr是从1开始的,而Random是从0开始的,SourceStr[0]就会报错,SourceStr[63]也会报错
    MyRep := MyRep + SourceStr[Random(61)+1];
  end;
  Exit(MyRep);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Caption:=SuiJiString(32);
end;

相关阅读 >>

Delphi system 中的数学函数

Delphi里formatfloat的用法

Delphi获取其他进程中状态栏文本的函数

Delphi中stringgrid删除行

Delphi 禁用本地网络连接/启用本地网络连接

Delphi 判断目录是否有写入权限

Delphi xe10 对 json的解析应用

Delphi 模糊查询和字段查询

Delphi access中只取时间的日期部分的函数

Delphi tnethttpcleint提交json串

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



打赏

取消

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

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

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

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

评论

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