Convertir des chiffres en lettres

mounakarim Messages postés 11 Date d'inscription samedi 2 décembre 2006 Statut Membre Dernière intervention 24 juin 2008 - 26 mai 2008 à 20:32
mounakarim Messages postés 11 Date d'inscription samedi 2 décembre 2006 Statut Membre Dernière intervention 24 juin 2008 - 27 mai 2008 à 04:12
Comment convertir des chiffres en lettres(en vb.net)?
par exemple 21,75 doit apparaitre sous la forme vingt et un dirham et soixante quinze centimes.
D'avaance merciiiiiii troooooooooooop.
karimos

6 réponses

cs_Dominike Messages postés 70 Date d'inscription jeudi 13 février 2003 Statut Membre Dernière intervention 6 mars 2010
26 mai 2008 à 21:02
Je dirai si tes 21,75 sont en cellule A1.
Inscrit en cellule B1 =ARRONDI.INF(F19;0) tu obtiens 21
Inscrit en cellule B2 =DROITE(A1;2) tu obtiens 75
Inscrit en cellule B3 = concatener (B1; "dihram(s)"; B2; " centimes")
 Peut-être y a t-il plus simple !... mais ça fonctionne.
-Dominike -
0
cs_Dominike Messages postés 70 Date d'inscription jeudi 13 février 2003 Statut Membre Dernière intervention 6 mars 2010
26 mai 2008 à 21:03
Je dirai si tes 21,75 sont en cellule A1.
Inscrit en cellule B1 =ARRONDI.INF(A1;0) tu obtiens 21
Inscrit en cellule B2 =DROITE(A1;2) tu obtiens 75
Inscrit en cellule B3 = concatener (B1; "dihram(s)"; B2; " centimes")
 Peut-être y a t-il plus simple !... mais ça fonctionne.
Pardon j'ai corrigé en rouge.

-Dominike -
0
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
26 mai 2008 à 21:10
 il veut pas avoir :

21 dirham et 75 centimes

mais

vingt et un dirham et soixante quinze centimes

c'est pas pareil.

il existe de nombreux code faisant cela sur code source, cherche avec les mots clefs "chiffre en lettre"
sur codyx doit y'en avoir aussi.

<hr size="2" width="100%" />
0
nawaleee Messages postés 1 Date d'inscription samedi 19 janvier 2008 Statut Membre Dernière intervention 26 mai 2008
26 mai 2008 à 21:25
cette fonction permet de convertie les chiffres en lettres

il faut importes

Option

Strict
OffOption

Explicit
OnImports

VB = Microsoft.VisualBasic
''''''''_______________________'''''

La fonction

Function

GetFigures(
ByRef x
As
String)
As
String

Dim one(10)
As
String

Dim two(10)
As
String

Dim Three(10)
As
String

Dim Hundred
As
String

Dim Thousand
As
String

Dim lakh
As
String

Dim Crore
As
String

Dim Billion
As
String

Dim Million
As
String

Dim Trillion
AsStringone(0) "zero" : one(1) "un" : one(2) "deux" : one(3) "trois" : one(4) "quatre" : one(5) "cinq" : one(6) "six" : one(7) "sept" : one(8) "huit" : one(9) "neuf"two(0) "dix" : two(1) "onze" : two(2) "douze" : two(3) "treize" : two(4) "quatorze" : two(5) "quinze" : two(6) "seize" : two(7) "dix-sept" : two(8) "dix-huit" : two(9) "dix-neuf"Three(2) "vingt" : Three(3) "trente" : Three(4) "quarante" : Three(5) "cinquante" : Three(6) "soixante" : Three(7) "soixante-dix" : Three(8) "quatre-vingts" : Three(9) "quatre-vingt-dix"Hundred "cent" : Thousand "Thousand" : lakh "Lakh" : Crore "Crore" : Billion "Billion"Million

"Million" : Trillion =
"Trillion"

"

Dim inp, RetVal
As
Stringinp =

CStr(Val(x)) 

Select
Case Len(inp)

Case 1RetVal = one(

CInt(x))

Case 2

If Int(
CDbl(VB.Right(inp, 1))) > 0
And
CDbl(VB.Left(inp, 1)) > 1
Then RetVal = GetFigures(
CStr(Int(
CDbl(VB.Right(inp, 1)))))
' from 20 to 90 step 10

If
CDbl(VB.Left(inp, 1)) > 1
Then RetVal = Three(
CInt(VB.Left(inp, 1))) & RetVal
' from 20-99

If
CDbl(VB.Left(inp, 1)) = 1
Then RetVal = two(
CInt(VB.Right(inp, 1)))
' from 11-19 range

Case 3

If Int(
CDbl(VB.Right(inp, 2))) > 0
Then RetVal = GetFigures(
CStr(Int(
CDbl(VB.Right(inp, 2)))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & Hundred & RetVal

Case 4

If Int(
CDbl(VB.Right(inp, 3))) > 0
Then RetVal = GetFigures(
CStr(Int(
CDbl(VB.Right(inp, 3)))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & Thousand & RetVal

Case 5

If Int(
CDbl(VB.Right(inp, 3))) > 0
Then RetVal = GetFigures(
CStr(Int(
CDbl(VB.Right(inp, 3)))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 2)))) & Thousand & RetVal

Case 6

If
CInt(VB.Right(inp, 5)) > 0
Then RetVal = GetFigures(
CStr(
CInt(VB.Right(inp, 5))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & lakh & RetVal

Case 7

If
CInt(VB.Right(inp, 5)) > 0
Then RetVal = GetFigures(
CStr(
CInt(VB.Right(inp, 5))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 2)))) & lakh & RetVal

Case 8

If
CInt(VB.Right(inp, 7)) > 0
Then RetVal = GetFigures(
CStr(
CInt(VB.Right(inp, 7))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & Crore & RetVal

Case 9

If
CInt(VB.Right(inp, 7)) > 0
Then RetVal = GetFigures(
CStr(
CInt(VB.Right(inp, 7))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 2)))) & Crore & RetVal

Case 10

If
CInt(VB.Right(inp, 9)) > 0
Then RetVal = GetFigures(
CStr(
CInt(VB.Right(inp, 9))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & Billion & RetVal

Case 11

If
CInt(VB.Right(inp, 9)) > 0
Then RetVal = GetFigures(
CStr(
CInt(VB.Right(inp, 9))))RetVal = GetFigures(Int(

CDbl(VB.Left(inp, 2)))) & Billion & RetVal

Case 12

If Val(VB.Right(inp, 11)) > 0 Then RetVal GetFigures(VB.Right(inp, 11))RetVal GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & Million & RetVal

Case 13

If Val(VB.Right(inp, 11)) > 0 Then RetVal GetFigures(VB.Right(inp, 11))RetVal GetFigures(Int(

CDbl(VB.Left(inp, 2)))) & Million & RetVal

Case 14

If Val(VB.Right(inp, 13)) > 0 Then RetVal GetFigures(VB.Right(inp, 13))RetVal GetFigures(Int(

CDbl(VB.Left(inp, 1)))) & Trillion & RetVal

Case 15

If Val(VB.Right(inp, 13)) > 0 Then RetVal GetFigures(VB.Right(inp, 13))RetVal GetFigures(Int(

CDbl(VB.Left(inp, 2)))) & Trillion & RetVal

End
SelectGetFigures =

" " & RetVal &
" "GetFigures = Replace(GetFigures,

" ",
" ")

End
Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''__________________________________________''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Une zone de text  dans elle en saisie les chifres
Private

Sub txtNumber_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtNumber.KeyPress

Dim KeyAscii
AsShort Asc(eventArgs.KeyChar)KeyAscii IIf(IsNumeric(Chr(KeyAscii))

Or (InStr(txtNumber.Text,
".") = 0
And KeyAscii = 46)
Or KeyAscii = 8, KeyAscii, 0)

If KeyAscii = 0
TheneventArgs.Handled =

True

End
If

End
Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''__________________________________________''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

On applet la fonction dasn un boutton

Private
Sub btnCalculate_Click(
ByVal eventSender
As System.Object,
ByVal eventArgs
As System.EventArgs)
Handles btnCalculate.ClicklblString.Text = GetFigures((txtNumber.Text))

End
Sub

Merciiiii   bon couragggggggggggggggges
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Dominike Messages postés 70 Date d'inscription jeudi 13 février 2003 Statut Membre Dernière intervention 6 mars 2010
26 mai 2008 à 21:37
Désolé, j'étais loin du compte en effet...

-Dominike -
0
mounakarim Messages postés 11 Date d'inscription samedi 2 décembre 2006 Statut Membre Dernière intervention 24 juin 2008
27 mai 2008 à 04:12
merci trop vrmt tu ma sauvééééééééé thanks lot
karimos
0
Rejoignez-nous