Access - Traducir un numero en text ( ingresa 20 y devuelva veinte)

 
Vista:

Traducir un numero en text ( ingresa 20 y devuelva veinte)

Publicado por Leonard Rodriguez (58 intervenciones) el 24/09/2014 23:29:59
Buenas tardes:

Estoy buscando alguna funcion que me ayude a convertir un numero en texto, esto se presta a confusion por eso coloco el ejemplo nuevamente ingresar en un campo el numero 20 y en otro campo devuelve en texto "veinte" y asi para cualquier numero.

Sera posible que me puedan ayudar, se agradece de antemano alguna guia, puede que no haya conseguido las palabras correctas para buscar este punto.

Gracias Nuevamente

Leonard Rodriguez
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 756
Plata
Ha mantenido su posición en Access (en relación al último mes)
Gráfica de Access

Traducir un numero en text ( ingresa 20 y devuelva veinte)

Publicado por Jesús Manuel (134 intervenciones) el 25/09/2014 10:55:29
En la web de Búho tienes varios ejemplos para pasar cantidades de monedas, con lo que podrías adaptar el código.

http://www.mvp-access.es/buho/ejemplos.htm

Pon en el buscador "número a letra"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de francesc

Traducir un numero en text ( ingresa 20 y devuelva veinte)

Publicado por francesc (68 intervenciones) el 26/09/2014 14:19:01
Por el foro he localizado este código que hay que insertar en un módolo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
Function letra(Numero)
Dim Texto
Dim Millones
Dim Miles
Dim Cientos
Dim Decimales
Dim Cadena
Dim CadMillones
Dim CadMiles
Dim CadCientos
Dim caddecimales
Texto = Round(Numero, 2)
Texto = FormatNumber(Texto, 2)
Texto = Right(Space(14) & Texto, 14)
Millones = Mid(Texto, 1, 3)
Miles = Mid(Texto, 5, 3)
Cientos = Mid(Texto, 9, 3)
Decimales = Mid(Texto, 13, 2)
CadMillones = ConvierteCifra(Millones, False)
CadMiles = ConvierteCifra(Miles, False)
CadCientos = ConvierteCifra(Cientos, True)
caddecimales = ConvierteDecimal(Decimales)
 
If Trim(CadMillones) > "" Then
If Trim(CadMillones) = "UN" Then
Cadena = CadMillones & " MILLON"
Else
Cadena = CadMillones & " MILLONES"
End If
End If
 
If Trim(CadMiles) > "" Then
If Trim(CadMiles) = "UN" Then
CadMiles = ""
Cadena = Cadena & "" & CadMiles & "MIL"
CadMiles = "UN"
Else
Cadena = Cadena & " " & CadMiles & " MIL"
End If
End If
If Trim(CadMiles) > "001" Then
CadMiles = "MIL"
End If
 
If Decimales = "00" Then
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "UN" Then
Cadena = Cadena & "UNO "
Else
If Miles & Cientos = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos)
Else
Cadena = Cadena & " " & Trim(CadCientos)
End If
letra = Trim(Cadena)
End If
Else
If Trim(CadMillones & CadMiles & CadCientos & caddecimales) = "UN" Then
Cadena = Cadena & "UNO " & "CON " & Trim(caddecimales)
Else
If Millones & Miles & Cientos & Decimales = "000000" Then
Cadena = Cadena & " " & Trim(CadCientos) & " PESOS " & Trim(Decimales) & "/100 M.N."
Else
Cadena = Cadena & " " & Trim(CadCientos) & " PESOS " & Trim(Decimales) & "/100 M.N."
End If
letra = Trim(Cadena)
End If
End If
 
End Function
 
Function ConvierteCifra(Texto, IsCientos As Boolean)
Dim Centena
Dim Decena
Dim Unidad
Dim txtCentena
Dim txtDecena
Dim txtUnidad
Centena = Mid(Texto, 1, 1)
Decena = Mid(Texto, 2, 1)
Unidad = Mid(Texto, 3, 1)
Select Case Centena
Case "1"
txtCentena = "CIEN"
If Decena & Unidad <> "00" Then
txtCentena = "CIENTO"
End If
Case "2"
txtCentena = "DOSCIENTOS"
Case "3"
txtCentena = "TRESCIENTOS"
Case "4"
txtCentena = "CUATROCIENTOS"
Case "5"
txtCentena = "QUINIENTOS"
Case "6"
txtCentena = "SEISCIENTOS"
Case "7"
txtCentena = "SETECIENTOS"
Case "8"
txtCentena = "OCHOCIENTOS"
Case "9"
txtCentena = "NOVECIENTOS"
End Select
 
Select Case Decena
Case "1"
txtDecena = "DIEZ"
Select Case Unidad
Case "1"
txtDecena = "ONCE"
Case "2"
txtDecena = "DOCE"
Case "3"
txtDecena = "TRECE"
Case "4"
txtDecena = "CATORCE"
Case "5"
txtDecena = "QUINCE"
Case "6"
txtDecena = "DIECISEIS"
Case "7"
txtDecena = "DIECISIETE"
Case "8"
txtDecena = "DIECIOCHO"
Case "9"
txtDecena = "DIECINUEVE"
End Select
Case "2"
txtDecena = "VEINTE"
If Unidad <> "0" Then
txtDecena = "VEINTI"
End If
Case "3"
txtDecena = "TREINTA"
If Unidad <> "0" Then
txtDecena = "TREINTA Y "
End If
Case "4"
txtDecena = "CUARENTA"
If Unidad <> "0" Then
txtDecena = "CUARENTA Y "
End If
Case "5"
txtDecena = "CINCUENTA"
If Unidad <> "0" Then
txtDecena = "CINCUENTA Y "
End If
Case "6"
txtDecena = "SESENTA"
 
If Unidad <> "0" Then
txtDecena = "SESENTA Y "
End If
Case "7"
txtDecena = "SETENTA"
If Unidad <> "0" Then
txtDecena = "SETENTA Y "
End If
Case "8"
txtDecena = "OCHENTA"
If Unidad <> "0" Then
txtDecena = "OCHENTA Y "
End If
Case "9"
txtDecena = "NOVENTA"
If Unidad <> "0" Then
txtDecena = "NOVENTA Y "
End If
End Select
 
If Decena <> "1" Then
Select Case Unidad
Case "1"
If IsCientos = False Then
txtUnidad = "UN"
Else
txtUnidad = "UNO"
End If
Case "2"
txtUnidad = "DOS"
Case "3"
txtUnidad = "TRES"
Case "4"
txtUnidad = "CUATRO"
Case "5"
txtUnidad = "CINCO"
Case "6"
txtUnidad = "SEIS"
Case "7"
txtUnidad = "SIETE"
Case "8"
txtUnidad = "OCHO"
Case "9"
txtUnidad = "NUEVE"
End Select
End If
ConvierteCifra = txtCentena & " " & txtDecena & txtUnidad
End Function
 
 
Function ConvierteDecimal(Texto)
Dim Decenadecimal
Dim Unidaddecimal
Dim txtDecenadecimal
Dim txtUnidaddecimal
Decenadecimal = Mid(Texto, 1, 1)
Unidaddecimal = Mid(Texto, 2, 1)
 
Select Case Decenadecimal
Case "1"
txtDecenadecimal = "DIEZ"
Select Case Unidaddecimal
Case "1"
txtDecenadecimal = "ONCE"
Case "2"
txtDecenadecimal = "DOCE"
Case "3"
txtDecenadecimal = "TRECE"
Case "4"
txtDecenadecimal = "CATORCE"
Case "5"
txtDecenadecimal = "QUINCE"
Case "6"
txtDecenadecimal = "DIECISEIS"
Case "7"
txtDecenadecimal = "DIECISIETE"
Case "8"
txtDecenadecimal = "DIECIOCHO"
Case "9"
txtDecenadecimal = "DIECINUEVE"
End Select
Case "2"
txtDecenadecimal = "VEINTE"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "VEINTI"
End If
Case "3"
txtDecenadecimal = "TREINTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "TREINTA Y "
End If
Case "4"
txtDecenadecimal = "CUARENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "CUARENTA Y "
End If
Case "5"
txtDecenadecimal = "CINCUENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "CINCUENTA Y "
End If
Case "6"
txtDecenadecimal = "SESENTA"
 
If Unidaddecimal <> "0" Then
txtDecenadecimal = "SESENTA Y "
End If
Case "7"
txtDecenadecimal = "SETENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "SETENTA Y "
End If
Case "8"
txtDecenadecimal = "OCHENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "OCHENTA Y "
End If
Case "9"
txtDecenadecimal = "NOVENTA"
If Unidaddecimal <> "0" Then
txtDecenadecimal = "NOVENTA Y "
End If
End Select
 
If Decenadecimal <> "1" Then
Select Case Unidaddecimal
Case "1"
txtUnidaddecimal = "UNO"
Case "2"
txtUnidaddecimal = "DOS"
Case "3"
txtUnidaddecimal = "TRES"
Case "4"
txtUnidaddecimal = "CUATRO"
Case "5"
txtUnidaddecimal = "CINCO"
Case "6"
txtUnidaddecimal = "SEIS"
Case "7"
txtUnidaddecimal = "SIETE"
Case "8"
txtUnidaddecimal = "OCHO"
Case "9"
txtUnidaddecimal = "NUEVE"
End Select
End If
If Decenadecimal = 0 And Unidaddecimal = 0 Then
ConvierteDecimal = ""
Else
ConvierteDecimal = txtDecenadecimal & txtUnidaddecimal
End If
End Function
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

Traducir un numero en text ( ingresa 20 y devuelva veinte)

Publicado por Leonard Rodriguez (58 intervenciones) el 26/09/2014 14:49:06
Muchisimas Gracis por su apoyo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar