Cita:
Empezado por Casimiro Notevi
Explicas poca cosa, pero lo normal es que pongas una máscara apropiada, algo así como: '#,##0.00'
|
Que tal Casimiro en verdad nose que mas necesitas saber quiza me exprese mal lo que yo quiero es que al sumarse los dos numero no me quite el cero del decimal pongo un ejemplo para que sea mas practico y desde ya muchas gracias
Código Delphi
[-]function StrToFloat_Universal( pText : string ): Extended; const EUROPEAN_ST = ',';
AMERICAN_ST = '.'; var lformatSettings : TFormatSettings;
lFinalValue : string;
lIndx : Byte;
lIsAmerican : Boolean;
lIsEuropean : Boolean;
begin lIsAmerican := False;
lIsEuropean := False;
for lIndx := Length( pText ) - 1 downto 0 do
begin
if ( pText[ lIndx ] = AMERICAN_ST ) then
begin
lIsAmerican := True;
pText := StringReplace( pText, ',', '', [ rfIgnoreCase, rfReplaceAll ]);
Break;
end;
if ( pText[ lIndx ] = EUROPEAN_ST ) then
begin
lIsEuropean := True;
pText := StringReplace( pText, '.', '', [ rfIgnoreCase, rfReplaceAll ]); Break; end; end; GetLocaleFormatSettings( LOCALE_SYSTEM_DEFAULT, lformatSettings );
if ( lformatSettings.DecimalSeparator = EUROPEAN_ST ) then
begin
if lIsAmerican then
begin
lFinalValue := StringReplace( pText, '.', ',', [ rfIgnoreCase, rfReplaceAll ] );
end;
end;
if ( lformatSettings.DecimalSeparator = AMERICAN_ST ) then
begin
if lIsEuropean then
begin
lFinalValue := StringReplace( pText, ',', '.', [ rfIgnoreCase, rfReplaceAll ] );
end;
end;
pText := lFinalValue; Result := StrToFloat( pText, lformatSettings );
end;
procedure TForm1.Button1Click(Sender: TObject);
var
N1:Real;
Begin
N1:= StrToFloat_Universal (Edit1.Text);
N1:= N1 + StrToFloat_Universal( Edit2.text);
Label1.Caption:= FloatToStr(N1);
end;
end.
Aqui uso esa funcion porque es la unica que me permitia sumar dos numeros del tipo 00,000,000.00 Gracias