function Calc: string;
const
  a = '12345678';
var
  I: Integer;
  J: Integer;
  L: Integer;
  T: Char;
begin
  Randomize;
  Result := a;
  L := Length(Result);
  for I := 1 to L do begin
    J := Random(L) + 1;
    T := Result[I];
    Result[I] := Result[J];
    Result[J] := T;
  end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  Caption := Calc;
end;