delphi RandString 随机字符串

2018-10-30

function RandString(s: string; Min, Max: Integer): string;
var
count, i, r : Integer;
begin
Result := '';
if ((Max - Min) > 0) then
begin
  count := Random(Max - Min + 1) + Min;
  for i := 0 to count - 1 do
  begin
   r := Random(Length(s)) + 1;
   Result := Result + s[r];
  end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(RandString('ABCDEFGHIJKLMN',9,10));
end;

阅读72