Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-10-2005
omy omy is offline
Miembro
 
Registrado: ago 2003
Ubicación: Acapulco gro.
Posts: 100
Poder: 21
omy Va por buen camino
Wink Pasar de numero a letras

Hola, no es un problema, ya lo hice en c++ , me preguntaba si ya existe un control para hacer que un numero lo lo lea y me de en forma de letras
__________________
omar velazquez
Responder Con Cita
  #2  
Antiguo 07-10-2005
Avatar de AGAG4
AGAG4 AGAG4 is offline
Miembro
 
Registrado: ago 2004
Ubicación: Los Mochis, Sinaloa, México
Posts: 1.420
Poder: 21
AGAG4 Va por buen camino
Prueba esto....

Prueba el siguiente código, a mi me funciona sin problemas... Suerte
Código Delphi [-]
 function xIntToLletras(Numero:LongInt):String;
   function xxIntToLletras(Valor:LongInt):String;
   const
    aUnidad : array[1..15] of String =
      ('UN','DOS','TRES','CUATRO','CINCO','SEIS',
       'SIETE','OCHO','NUEVE','DIEZ','ONCE','DOCE',
       'TRECE','CATORCE','QUINCE');
    aCentena: array[1..9]  of String =
      ('CIENTO','DOSCIENTOS','TRESCIENTOS',
       'CUATROCIENTOS','QUINIENTOS','SEISCIENTOS',
       'SETECIENTOS','OCHOCIENTOS','NOVECIENTOS');
    aDecena : array[1..9]  of String =
     ('DIECI','VEINTI','TREINTA','CUARENTA','CINCUENTA',
      'SESENTA','SETENTA','OCHENTA','NOVENTA');
   var
    Centena, Decena, Unidad, Doble: LongInt;
    Linea: String;
   begin
    if valor=100 then Linea:=' CIEN '
    else begin
      Linea:='';
      Centena := Valor div 100;
      Doble   := Valor - (Centena*100);
      Decena  := (Valor div 10) - (Centena*10);
      Unidad  := Valor - (Decena*10) - (Centena*100);
      if Centena>0 then Linea := Linea + Acentena[centena]+' ';
      if Doble>0 then begin
        if Doble=20 then Linea := Linea +' VEINTE '
          else begin
           if doble<16 then Linea := Linea + aUnidad[Doble]
             else begin
                  Linea := Linea +' '+ Adecena[Decena];
                  if (Decena>2) and (Unidad<>0) then Linea := Linea+' Y ';
                  if Unidad>0 then Linea := Linea + aUnidad[Unidad];
             end;
          end;
      end;
    end;
    Result := Linea;
   end;
 var
   Millones,Miles,Unidades: Longint;
   Linea : String;
 begin
   {Inicializamos el string que contendrá las letras según el valor
   numérico}
   if numero=0 then Linea := 'CERO'
   else if numero<0 then Linea := 'MENOS '
        else if numero=1 then
             begin
               Linea := 'UN';
               xIntToLletras := Linea;
               exit
             end
             else if numero>1 then Linea := '';
   {Determinamos el Nº de millones, miles y unidades de numero en
   positivo}
   Numero   := Abs(Numero);
   Millones := numero div 1000000;
   Miles     := (numero - (Millones*1000000)) div 1000;
   Unidades  := numero - ((Millones*1000000)+(Miles*1000));
   {Vamos poniendo en el string las cadenas de los números(llamando
   a subfuncion)}
   if Millones=1 then Linea:= Linea + ' UN MILLON '
   else if Millones>1 then Linea := Linea + xxIntToLletras(Millones)
                                    + ' MILLONES ';
   if Miles =1 then Linea:= Linea + ' MIL '
   else if Miles>1 then Linea := Linea + xxIntToLletras(Miles)+
                                 ' MIL ';
   if Unidades >0 then Linea := Linea + xxIntToLletras(Unidades);
   xIntToLletras := Linea;
 end;

//function DameImpConLetra(Importe:String, Moneda:byte):String;
function DameImpConLetra(Importe:String; Moneda:byte):String;
var
  x:byte;
  Decim,Miles:String;
begin
  decim:='00';
  miles:='';
  for x:=1 to length(importe) do
    if importe[x]='.' then begin
      Miles:=copy(importe,1,x-1);
      Decim:=copy(importe,x+1,2);
    end;
  //Determinar el Tipo de Moneda
  if miles<>'' then begin
    if Moneda=1 then //Si es en PESOS Entonces
      result:='('+xIntToLletras(StrToInt(Miles))+' PESOS '+Decim+'/100 M.N.)'
    else             //Si es en DOLARES Entonces
      result:='('+xIntToLletras(StrToInt(Miles))+' DOLARES '+Decim+'/100 U.S.D.)';
  end else
    if Moneda=1 then //Si es en PESOS Entonces
      result:='('+xIntToLletras(StrToInt(importe))+' PESOS '+Decim+'/100 M.N.)'
    else             //Si es en DOLARES Entonces
      result:='('+xIntToLletras(StrToInt(importe))+' DOLARES '+Decim+'/100 U.S.D.)';
end;

Saludos....
Responder Con Cita
  #3  
Antiguo 07-10-2005
Avatar de Sotrono
Sotrono Sotrono is offline
Miembro
 
Registrado: abr 2004
Ubicación: Buenos Aires - Argentina
Posts: 396
Poder: 21
Sotrono Va por buen camino
Si, esta en la seccion "Componentes" de la web.

Saludos...
Responder Con Cita
  #4  
Antiguo 09-10-2005
omy omy is offline
Miembro
 
Registrado: ago 2003
Ubicación: Acapulco gro.
Posts: 100
Poder: 21
omy Va por buen camino
Talking Gracias...

Gracias, ya lo realize de las dos formas.... gracias....
__________________
omar velazquez
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 00:02:20.


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
Copyright 1996-2007 Club Delphi