本文整理自网络,侵删。
function RandomStr(majuscule:boolean;lowercase:boolean;number:boolean;digit:integer):string;
//大写字母,小写字母,数字,字符串的位数
var
i: Byte;
s: string;
begin
if majuscule then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';
if lowercase then
s := s + 'abcdefghijklmnopqrstuvwxyz';
if number then
s := s + '0123456789';
if s = '' then exit;
Result := '';
for i := 0 to digit-1 do //根据长度来循环
begin
Randomize;//每次都初始化随机种子
Result := Result + s[Random(Length(s)-1)+1];
end;
end;
相关阅读 >>
Delphi stringgrid 实例4 本例功能: 1、给每个单元格赋值 2、调整当前单元格位置:上下左右;
Delphi windows 编程[15] - 菜单消息: wm_command
更多相关阅读请进入《Delphi》频道 >>