🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #2279

Re: Texto en factura

#2279
From: cbd
Date: Mon, 16 Jan 2006 21:21
84 lines
4199 bytes
Gracias Mauricio, lo traspas� a C++ y me qued� operando de lujo.



Mauricio G�mez wrote:

> cbd escribi�:
>> Amigos, tengo que implementar en forma urgente un algoritmo para un
>> programa en C++ que me transforme el valor total num�rico de la factura a
>> texto, o sea por ejemplo si la factura es por $540.569 me ponga
>> Quinientos cuarenta mil quinientos sesenta y nueve.
>> Alguien por ah� sabe del algoritmo en cuesti�n?
>> 
>> Gracias desde ya
>> 
> 
> Esta en VB pero no debiera ser drama pasarlo a C++:
> 
> Public Function Num2Text(value As Double) As String
> Select Case value
>      Case 0: Num2Text = "CERO"
>      Case 1: Num2Text = "UN"
>      Case 2: Num2Text = "DOS"
>      Case 3: Num2Text = "TRES"
>      Case 4: Num2Text = "CUATRO"
>      Case 5: Num2Text = "CINCO"
>      Case 6: Num2Text = "SEIS"
>      Case 7: Num2Text = "SIETE"
>      Case 8: Num2Text = "OCHO"
>      Case 9: Num2Text = "NUEVE"
>      Case 10: Num2Text = "DIEZ"
>      Case 11: Num2Text = "ONCE"
>      Case 12: Num2Text = "DOCE"
>      Case 13: Num2Text = "TRECE"
>      Case 14: Num2Text = "CATORCE"
>      Case 15: Num2Text = "QUINCE"
>      Case Is < 20: Num2Text = "DIECI" & Num2Text(value - 10)
>      Case 20: Num2Text = "VEINTE"
>      Case Is < 30: Num2Text = "VEINTI" & Num2Text(value - 20)
>      Case 30: Num2Text = "TREINTA"
>      Case 40: Num2Text = "CUARENTA"
>      Case 50: Num2Text = "CINCUENTA"
>      Case 60: Num2Text = "SESENTA"
>      Case 70: Num2Text = "SETENTA"
>      Case 80: Num2Text = "OCHENTA"
>      Case 90: Num2Text = "NOVENTA"
>      Case Is < 100: Num2Text = Num2Text(Int(value \ 10) * 10) & " Y " &
> Num2Text(value Mod 10)
>      Case 100: Num2Text = "CIEN"
>      Case Is < 200: Num2Text = "CIENTO " & Num2Text(value - 100)
>      Case 200, 300, 400, 600, 800: Num2Text = Num2Text(Int(value \ 100)) &
> "CIENTOS"
>      Case 500: Num2Text = "QUINIENTOS"
>      Case 700: Num2Text = "SETECIENTOS"
>      Case 900: Num2Text = "NOVECIENTOS"
>      Case Is < 1000: Num2Text = Num2Text(Int(value \ 100) * 100) & " " &
> Num2Text(value Mod 100)
>      Case 1000: Num2Text = "MIL"
>      Case Is < 2000: Num2Text = "MIL " & Num2Text(value Mod 1000)
>      Case Is < 1000000: Num2Text = Num2Text(Int(value \ 1000)) & " MIL"
>                         If value Mod 1000 Then Num2Text = Num2Text & " " &
> Num2Text(value Mod 1000)
>      Case 1000000: Num2Text = "UN MILLON"
>      Case Is < 2000000: Num2Text = "UN MILLON " & Num2Text(value Mod
> 1000000)
>      Case Is < 1000000000000#: Num2Text = Num2Text(Int(value / 1000000)) &
>      "
> MILLONES"
>                                If (value - Int(value / 1000000) * 1000000)
> Then Num2Text = Num2Text & " " & Num2Text(value - Int(value / 1000000) *
> 1000000)
>      Case 1000000000000#: Num2Text = "UN BILLON"
>      Case Is < 2000000000000#: Num2Text = "UN BILLON " & Num2Text(value -
> Int(value / 1000000000000#) * 1000000000000#)
>      Case Else:
>             Num2Text = Num2Text(Int(value / 1000000000000#)) & " BILLONES"
>             If (value - Int(value / 1000000000000#) * 1000000000000#) Then
> Num2Text = Num2Text & " " & Num2Text(value - Int(value / 1000000000000#) *
> 1000000000000#)
> End Select
> End Function
> 
> 
> rro
Technical Details
Message-ID: <dqhd84$f51$1@news.nivel5.cl>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!not-for-mail
References: <dqgjs7$a7a$1@news.nivel5.cl> <dqgqgh$bov$1@news.nivel5.cl>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,2f3a609e66c4b540
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!not-for-mail
From: cbd <cbazan@_NO__S_PA_M_vtr.net>
Newsgroups: chile.comp.programacion
Subject: Re: Texto en factura
Date: Mon, 16 Jan 2006 21:21:30 +0000
Organization: Varios
Lines: 85
Message-ID: <dqhd84$f51$1@news.nivel5.cl>
References: <dqgjs7$a7a$1@news.nivel5.cl> <dqgqgh$bov$1@news.nivel5.cl>
NNTP-Posting-Host: pc-139-5-83-200.cm.vtr.net
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit
X-Trace: news.nivel5.cl 1137457220 15521 200.83.5.139 (17 Jan 2006 00:20:20 GMT)
X-Complaints-To: news@news.nivel5.cl
NNTP-Posting-Date: Tue, 17 Jan 2006 00:20:20 +0000 (UTC)
User-Agent: KNode/0.9.2