Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Pasar de string a float (https://www.clubdelphi.com/foros/showthread.php?t=15789)

joanajj 04-11-2004 19:39:48

Pasar de string a float
 
Buenas a todos, quisiera hacer esto:

Recibo este valor en string. Por ej. valor='123456789'
y quiero pasarlo a numérico y que quede así: 123456,789

¿Cómo podría hacerlo???


Saludos....

vic_ia 04-11-2004 19:50:03

Hola...
Código Delphi [-]
function mostrar(valor : string):string;
var
  dato : Double;
begin
  dato  := StrToFloat(valor);
  result := FormatFloat('######,###',dato);
end;
saludos....

marcoszorrilla 04-11-2004 20:05:29

Otro ejemplo:
Código Delphi [-]
  procedure TForm1.Button1Click(Sender: TObject);
  var
  cCadena:String;
  nNumero:Double;
  begin
  cCadena:='123456789';
  nNumero:=StrToFloat(cCadena) /1000;
  ShowMessage(FormatFloat(',0.000',nNumero)); //Para comprobar el resultado
  end;
Un Saludo.

joanajj 04-11-2004 20:29:30

Gracias
 
Gracias por la rápida respuesta.


La franja horaria es GMT +2. Ahora son las 17:13:21.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi