以下是随机产生一个8位字符串:只包括数字和大小写字符
randomize();
edit1.Text :='';
for i:=0 to 7 do
begin
j:=random(61);
case j of
0..9:j:=j+48;
10..35:j:=j+55;
36..61:j:=j+61;
end;
edit1.Text :=edit1.Text+chr(j);
end;
randomize();
edit1.Text :='';
for i:=0 to 7 do
begin
j:=random(61);
case j of
0..32:j:=j+2;
33..51:j:=j+55;
52..61:j:=j+61;
end;
edit1.Text :=edit1.Text+chr(j);
end;
随便改啦,最好不要小于#32
procedure TForm1.Button2Click(Sender: TObject);
const
s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()&*^%$#@!~`;:"<>,.//|''';
var
n,i:integer;
ss:string;
begin
randomize();
n:=length(s);
ss:='';
for i:=0 to 7 do
ss:=ss+s[random+1];
showmessage(ss);
end;