您的位置:首页 > 其它

随机生成字符串

2007-03-11 19:03 423 查看
function btnGenerateClick(Sender: TObject): string;

{max length of generated password}

const
intMAX_PW_LEN = 10;
var
i: Byte;
s: string;
begin
{if you want to use the 'A..Z' characters}

if cbAZ.Checked then
s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
else
s := '';

{if you want to use the 'a..z' characters}

if cbAZSmall.Checked then
s := s + 'abcdefghijklmnopqrstuvwxyz';

{if you want to use the '0..9' characters}

if cb09.Checked then
s := s + '0123456789';
if s = '' then exit;

Result := '';
for i := 0 to intMAX_PW_LEN-1 do

Result := Result + s[Random(Length(s)-1)+1];
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: