Ver Mensaje Individual
  #13  
Antiguo 09-05-2022
Avatar de movorack
[movorack] movorack is offline
Miguel A. Valero
 
Registrado: feb 2007
Ubicación: Bogotá - Colombia
Posts: 1.346
Reputación: 20
movorack Va camino a la famamovorack Va camino a la fama
Hola bulc, que bien que ya lo hayas solucionado.

Te comparto otra posible solución. La idea es interactuar con el memo lo menos posible para que sea mas eficiente.

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
  function getListaDesordenada(const Max: Integer): TArray< string >;
  var
    i: Integer;
    lList: TList < Integer >;
  begin
    Result := [];

    lList:= TList < Integer >.Create;
    try
      for i := 1 to Max do
        lList.Add(i);

     for i := lList.Count-1 downto 0 do
        lList.Exchange(i, Random(i+1));

      for i := 0 to lList.Count - 1 do
        Result := Result  + [Format('%.2d', [lList[i]])];
    finally
      lList.Free;
    end;
  end;

  var
    lMax: Integer;
begin
  if (not TryStrToInt(edtMax.Text, lMax))
    or (lMax = 0)
  then
    Exit;

  Memo1.Lines.Clear;
  Memo1.Lines.AddStrings(getListaDesordenada(lMax));
end;
__________________
Buena caza y buen remar... http://mivaler.blogspot.com
Responder Con Cita