|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
CONVERTION DE CHIFFRES EN LETTRES
Information sur la source
Description
ce n'est pas une grande application ..bien sure !, mais un petit exemple particulier qui peut etre utile dans les traitements de textes (pas de calcul !!!)
Source
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- Edit1: TEdit;
- Edit2: TEdit;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- private
- { Déclarations privées }
- public
- { Déclarations publiques }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.Button1Click(Sender: TObject);
- function Chif (X: Byte) : String; { NOM DES CHIFFRES }
- begin
- case X of
- 0: Chif := 'zéro';
- 1: Chif := 'un';
- 2: Chif := 'deux';
- 3: Chif := 'trois';
- 4: Chif := 'quatre';
- 5: Chif := 'cinq';
- 6: Chif := 'six';
- 7: Chif := 'sept';
- 8: Chif := 'huit';
- 9: Chif := 'neuf';
- 10: Chif := 'dix';
- 11: Chif := 'onze';
- 12: Chif := 'douze';
- 13: Chif := 'treize';
- 14: Chif := 'quatorze';
- 15: Chif := 'quinze';
- 16: Chif := 'seize';
- 17: Chif := 'dix-sept';
- 18: Chif := 'dix-huit';
- 19: Chif := 'dix-neuf';
- 20: Chif := 'vingt';
- 21: Chif := 'vingt un';
- 22: Chif := 'vingt deux';
- 23: Chif := 'vingt trois';
- 24: Chif := 'vingt quatre';
- 25: Chif := 'vingt cinq';
- 26: Chif := 'vingt six';
- 27: Chif := 'vingt sept';
- 28: Chif := 'vingt huit';
- 29: Chif := 'vingt neuf';
- 30: Chif := 'trente';
- 31: Chif := 'trente un';
- 32: Chif := 'trente deux';
- 33: Chif := 'trente trois';
- 34: Chif := 'trente quatre';
- 35: Chif := 'trente cinq';
- 36: Chif := 'trente six';
- 37: Chif := 'trente sept';
- 38: Chif := 'trente huit';
- 39: Chif := 'trente neuf';
- 40: Chif := 'quarante';
- 41: Chif := 'quarante un';
- 42: Chif := 'quarante deux';
- 43: Chif := 'quarante trois';
- 44: Chif := 'quarante quatre';
- 45: Chif := 'quarante cinq';
- 46: Chif := 'quarante six';
- 47: Chif := 'quarante sept';
- 48: Chif := 'quarante huit';
- 49: Chif := 'quarante neuf';
- 50: Chif := 'cinquante';
- 51: Chif := 'cinquante un';
- 52: Chif := 'cinquante deux';
- 53: Chif := 'cinquante trois';
- 54: Chif := 'cinquante quatre';
- 55: Chif := 'cinquante cinq';
- 56: Chif := 'cinquante six';
- 57: Chif := 'cinquante sept';
- 58: Chif := 'cinquante huit';
- 59: Chif := 'cinquante neuf';
- 60: Chif := 'soixante';
- 61: Chif := 'soixante un';
- 62: Chif := 'soixante deux';
- 63: Chif := 'soixante trois';
- 64: Chif := 'soixante quatre';
- 65: Chif := 'soixante cinq';
- 66: Chif := 'soixante six';
- 67: Chif := 'soixante sept';
- 68: Chif := 'soixante huit';
- 69: Chif := 'soixante neuf';
- 70: Chif := 'soixante-dix';
- 71: Chif := 'soixante-onze';
- 72: Chif := 'soixante-douze';
- 73: Chif := 'soixante-treize';
- 74: Chif := 'soixante-quatorze';
- 75: Chif := 'soixante-quinze';
- 76: Chif := 'soixante-seize';
- 77: Chif := 'soixante-dix-sept';
- 78: Chif := 'soixante-dix-huit';
- 79: Chif := 'soixante-dix-neuf';
- 80: Chif := 'quatre-vingt';
- 81: Chif := 'quatre-vingt un';
- 82: Chif := 'quatre-vingt deux';
- 83: Chif := 'quatre-vingt trois';
- 84: Chif := 'quatre-vingt quatre';
- 85: Chif := 'quatre-vingt cinq';
- 86: Chif := 'quatre-vingt six';
- 87: Chif := 'quatre-vingt sept';
- 88: Chif := 'quatre-vingt huit';
- 89: Chif := 'quatre-vingt neuf';
- 90: Chif := 'quatre-vingt-dix';
- 91: Chif := 'quatre-vingt-onze';
- 92: Chif := 'quatre-vingt-douze';
- 93: Chif := 'quatre-vingt-treize';
- 94: Chif := 'quatre-vingt-quatorze';
- 95: Chif := 'quatre-vingt-quinze';
- 96: Chif := 'quatre-vingt-seize';
- 97: Chif := 'quatre-vingt-dix-sept';
- 98: Chif := 'quatre-vingt-dix-huit';
- 99: Chif := 'quatre-vingt-dix-neuf';
- 100:chif := ' cent ';
- end;
- end;
-
- function Nomp (X: Byte) : String; {NOM DES PUISSANCES}
- begin
- case x of
- 1: nomp:=' cent ';
- 2:nomp:=' mille ';
- 3:nomp:=' million ';
- 4:nomp:=' milliard ';
- end;
- end;
-
-
- function nbcar(N: LongInt) : String;{DEBUT DU TRAITEMENT DE LA FONCTION (N) }
- var
- s1,s2,txt,TmpTxt: String;
- x1,x2: longint;
- begin
- Str (N, TmpTxt);
- txt := '';
- {DIZAINE}
- if length(tmptxt)<3 then
- begin
- x1:=strtoint(tmptxt);
- txt:=txt+chif(x1);
- nbcar:=txt;
- end;
- if length(tmptxt)=3 then
- begin
- x2:=(strtoint(tmptxt[2]+tmptxt[3]));
- if x2>0 then
- s2:=chif(x2)
- else
- s2:='' ;
- x1:=strtoint(tmptxt[1]);
- if x1<>1 then
- s1:=chif(x1)+nomp(1)
- else
- s1:=nomp(1);
- txt:=s1+s2;
- nbcar:=txt
- end;
- end;{fin}{FIN DE LA FONCTION DE TRAITEMENT }
- procedure Affiche(x: longint;var st:string);{AFFICHAGE DU RESULTAT APRES TRAITEMENT}
- begin
- st:=(NbCar(x));
- end;
- var
- dec,txt,tmptxt,s1,s2,s3:string;
- x1,x2,x3:Longint;
- centi:integer;
-
- begin { Affiche un nombres entier }
- if pos('.',edit1.text) = 0 then
- begin
- tmptxt:=(edit1.text);
- centi:=0;
- affiche(centi,dec);
- end
- else
- begin { Affiche un nombres réel }
- tmptxt:=copy(edit1.text,0,pos('.',edit1.text)-1);
- dec:=copy(edit1.text,pos('.',edit1.text)+1,length(edit1.text));
- centi:=strtoint(dec);
- affiche(centi,dec);
-
- end;
-
- if length(tmptxt)<=3 then
- begin
- x1:=strtoint(tmptxt);
- affiche(x1,s1);
- txt:=txt+s1+' Dinars Algeriens et '+dec+' Centime.'
- end
- else
- case length(tmptxt) of
- 4:begin
- txt:='';
- s1:=tmptxt[1];
- s2:=copy(tmptxt,2,3);
- x1:=strtoint(s1);
- x2:=strtoint(s2);
- affiche(x1,s1);
- affiche(x2,s2);
- if x1<>1 then
- begin
- affiche(x1,s1);
- affiche(x2,s2);
- if x2=0 then
- s2:='';
- txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
- end
- else
- begin
- if x2=0 then
- s2:='';
- txt:=txt+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
- end;
- end;
- 5:begin
- txt:='';
- s1:=copy(tmptxt,1,2);
- s2:=copy(tmptxt,3,3);
- x1:=strtoint(s1);
- x2:=strtoint(s2);
- affiche(x1,s1);
- affiche(x2,s2);
- if x2=0 then
- s2:='';
- txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
- end;
- 6:begin
- txt:='';
- s1:=copy(tmptxt,1,3);
- s2:=copy(tmptxt,4,3);
- x1:=strtoint(s1);
- x2:=strtoint(s2);
- affiche(x1,s1);
- affiche(x2,s2);
- if x2=0 then
- s2:='';
- txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
- end;
-
-
- 7:begin
- txt:='';
- s1:=tmptxt[1];
- s2:=copy(tmptxt,2,3);
- s3:=copy(tmptxt,5,3);
- x1:=strtoint(s1);
- x2:=strtoint(s2);
- x3:=strtoint(s3);
- affiche(x1,s1);
- affiche(x2,s2);
- affiche(x3,s3);
- txt:=txt+s1+nomp(3)+s2+nomp(2)+s3+' Dinars Algeriens et '+dec+' Centime.'
- end;
-
- 8:begin
- txt:='';
- s1:=copy(tmptxt,1,2);
- s2:=copy(tmptxt,3,3);
- s3:=copy(tmptxt,6,3);
- x1:=strtoint(s1);
- x2:=strtoint(s2);
- x3:=strtoint(s3);
- affiche(x1,s1);
- affiche(x2,s2);
- affiche(x3,s3);
- if x2=0 then
- s2:='';
- if x3=0 then
- s3:='';
- txt:=txt+s1+nomp(2)+s2+nomp(1)+s3+' Dinars Algeriens et '+dec+' Centime.'
- end;
- 9:begin
- txt:='';
- s1:=copy(tmptxt,1,3);
- s2:=copy(tmptxt,4,3);
- s3:=copy(tmptxt,7,3);
- x1:=strtoint(s1);
- x2:=strtoint(s2);
- x3:=strtoint(s3);
- affiche(x1,s1);
- affiche(x2,s2);
- affiche(x3,s3);
- if x2=0 then
- s2:='';
- if x3=0 then
- s3:='';
- txt:=txt+s1+nomp(3)+s2+nomp(2)+s3+' Dinars Algeriens et '+dec+' Centime.'
- end;
- end;
- edit2.text:='Arrete la presente facture à la somme de :'+txt;
- end;
- end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
function Chif (X: Byte) : String; { NOM DES CHIFFRES }
begin
case X of
0: Chif := 'zéro';
1: Chif := 'un';
2: Chif := 'deux';
3: Chif := 'trois';
4: Chif := 'quatre';
5: Chif := 'cinq';
6: Chif := 'six';
7: Chif := 'sept';
8: Chif := 'huit';
9: Chif := 'neuf';
10: Chif := 'dix';
11: Chif := 'onze';
12: Chif := 'douze';
13: Chif := 'treize';
14: Chif := 'quatorze';
15: Chif := 'quinze';
16: Chif := 'seize';
17: Chif := 'dix-sept';
18: Chif := 'dix-huit';
19: Chif := 'dix-neuf';
20: Chif := 'vingt';
21: Chif := 'vingt un';
22: Chif := 'vingt deux';
23: Chif := 'vingt trois';
24: Chif := 'vingt quatre';
25: Chif := 'vingt cinq';
26: Chif := 'vingt six';
27: Chif := 'vingt sept';
28: Chif := 'vingt huit';
29: Chif := 'vingt neuf';
30: Chif := 'trente';
31: Chif := 'trente un';
32: Chif := 'trente deux';
33: Chif := 'trente trois';
34: Chif := 'trente quatre';
35: Chif := 'trente cinq';
36: Chif := 'trente six';
37: Chif := 'trente sept';
38: Chif := 'trente huit';
39: Chif := 'trente neuf';
40: Chif := 'quarante';
41: Chif := 'quarante un';
42: Chif := 'quarante deux';
43: Chif := 'quarante trois';
44: Chif := 'quarante quatre';
45: Chif := 'quarante cinq';
46: Chif := 'quarante six';
47: Chif := 'quarante sept';
48: Chif := 'quarante huit';
49: Chif := 'quarante neuf';
50: Chif := 'cinquante';
51: Chif := 'cinquante un';
52: Chif := 'cinquante deux';
53: Chif := 'cinquante trois';
54: Chif := 'cinquante quatre';
55: Chif := 'cinquante cinq';
56: Chif := 'cinquante six';
57: Chif := 'cinquante sept';
58: Chif := 'cinquante huit';
59: Chif := 'cinquante neuf';
60: Chif := 'soixante';
61: Chif := 'soixante un';
62: Chif := 'soixante deux';
63: Chif := 'soixante trois';
64: Chif := 'soixante quatre';
65: Chif := 'soixante cinq';
66: Chif := 'soixante six';
67: Chif := 'soixante sept';
68: Chif := 'soixante huit';
69: Chif := 'soixante neuf';
70: Chif := 'soixante-dix';
71: Chif := 'soixante-onze';
72: Chif := 'soixante-douze';
73: Chif := 'soixante-treize';
74: Chif := 'soixante-quatorze';
75: Chif := 'soixante-quinze';
76: Chif := 'soixante-seize';
77: Chif := 'soixante-dix-sept';
78: Chif := 'soixante-dix-huit';
79: Chif := 'soixante-dix-neuf';
80: Chif := 'quatre-vingt';
81: Chif := 'quatre-vingt un';
82: Chif := 'quatre-vingt deux';
83: Chif := 'quatre-vingt trois';
84: Chif := 'quatre-vingt quatre';
85: Chif := 'quatre-vingt cinq';
86: Chif := 'quatre-vingt six';
87: Chif := 'quatre-vingt sept';
88: Chif := 'quatre-vingt huit';
89: Chif := 'quatre-vingt neuf';
90: Chif := 'quatre-vingt-dix';
91: Chif := 'quatre-vingt-onze';
92: Chif := 'quatre-vingt-douze';
93: Chif := 'quatre-vingt-treize';
94: Chif := 'quatre-vingt-quatorze';
95: Chif := 'quatre-vingt-quinze';
96: Chif := 'quatre-vingt-seize';
97: Chif := 'quatre-vingt-dix-sept';
98: Chif := 'quatre-vingt-dix-huit';
99: Chif := 'quatre-vingt-dix-neuf';
100:chif := ' cent ';
end;
end;
function Nomp (X: Byte) : String; {NOM DES PUISSANCES}
begin
case x of
1: nomp:=' cent ';
2:nomp:=' mille ';
3:nomp:=' million ';
4:nomp:=' milliard ';
end;
end;
function nbcar(N: LongInt) : String;{DEBUT DU TRAITEMENT DE LA FONCTION (N) }
var
s1,s2,txt,TmpTxt: String;
x1,x2: longint;
begin
Str (N, TmpTxt);
txt := '';
{DIZAINE}
if length(tmptxt)<3 then
begin
x1:=strtoint(tmptxt);
txt:=txt+chif(x1);
nbcar:=txt;
end;
if length(tmptxt)=3 then
begin
x2:=(strtoint(tmptxt[2]+tmptxt[3]));
if x2>0 then
s2:=chif(x2)
else
s2:='' ;
x1:=strtoint(tmptxt[1]);
if x1<>1 then
s1:=chif(x1)+nomp(1)
else
s1:=nomp(1);
txt:=s1+s2;
nbcar:=txt
end;
end;{fin}{FIN DE LA FONCTION DE TRAITEMENT }
procedure Affiche(x: longint;var st:string);{AFFICHAGE DU RESULTAT APRES TRAITEMENT}
begin
st:=(NbCar(x));
end;
var
dec,txt,tmptxt,s1,s2,s3:string;
x1,x2,x3:Longint;
centi:integer;
begin { Affiche un nombres entier }
if pos('.',edit1.text) = 0 then
begin
tmptxt:=(edit1.text);
centi:=0;
affiche(centi,dec);
end
else
begin { Affiche un nombres réel }
tmptxt:=copy(edit1.text,0,pos('.',edit1.text)-1);
dec:=copy(edit1.text,pos('.',edit1.text)+1,length(edit1.text));
centi:=strtoint(dec);
affiche(centi,dec);
end;
if length(tmptxt)<=3 then
begin
x1:=strtoint(tmptxt);
affiche(x1,s1);
txt:=txt+s1+' Dinars Algeriens et '+dec+' Centime.'
end
else
case length(tmptxt) of
4:begin
txt:='';
s1:=tmptxt[1];
s2:=copy(tmptxt,2,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
affiche(x1,s1);
affiche(x2,s2);
if x1<>1 then
begin
affiche(x1,s1);
affiche(x2,s2);
if x2=0 then
s2:='';
txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end
else
begin
if x2=0 then
s2:='';
txt:=txt+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end;
end;
5:begin
txt:='';
s1:=copy(tmptxt,1,2);
s2:=copy(tmptxt,3,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
affiche(x1,s1);
affiche(x2,s2);
if x2=0 then
s2:='';
txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end;
6:begin
txt:='';
s1:=copy(tmptxt,1,3);
s2:=copy(tmptxt,4,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
affiche(x1,s1);
affiche(x2,s2);
if x2=0 then
s2:='';
txt:=txt+s1+nomp(2)+s2+' Dinars Algeriens et '+dec+' Centime.'
end;
7:begin
txt:='';
s1:=tmptxt[1];
s2:=copy(tmptxt,2,3);
s3:=copy(tmptxt,5,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
x3:=strtoint(s3);
affiche(x1,s1);
affiche(x2,s2);
affiche(x3,s3);
txt:=txt+s1+nomp(3)+s2+nomp(2)+s3+' Dinars Algeriens et '+dec+' Centime.'
end;
8:begin
txt:='';
s1:=copy(tmptxt,1,2);
s2:=copy(tmptxt,3,3);
s3:=copy(tmptxt,6,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
x3:=strtoint(s3);
affiche(x1,s1);
affiche(x2,s2);
affiche(x3,s3);
if x2=0 then
s2:='';
if x3=0 then
s3:='';
txt:=txt+s1+nomp(2)+s2+nomp(1)+s3+' Dinars Algeriens et '+dec+' Centime.'
end;
9:begin
txt:='';
s1:=copy(tmptxt,1,3);
s2:=copy(tmptxt,4,3);
s3:=copy(tmptxt,7,3);
x1:=strtoint(s1);
x2:=strtoint(s2);
x3:=strtoint(s3);
affiche(x1,s1);
affiche(x2,s2);
affiche(x3,s3);
if x2=0 then
s2:='';
if x3=0 then
s3:='';
txt:=txt+s1+nomp(3)+s2+nomp(2)+s3+' Dinars Algeriens et '+dec+' Centime.'
end;
end;
edit2.text:='Arrete la presente facture à la somme de :'+txt;
end;
end.
Conclusion
Ceci n'est que le code source de mon petit exemple pour avoir une petite idee de ce qu'on peut faire avec les instructions de traitement de texte, je m'excuse pour le fichier zip qui seras joint d'ici quelques temp avec tout les details. Merci pour votre comprehension sagit_terre@inbox.com
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Historique
- 26 octobre 2005 00:36:09 :
- eh bien voila le zip promis...merci pour l'attente
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Diiférencier les chiffres des lettres dans une string? [ par kwentinn ]
Salut tt le monde!J'aimerais savoir s'il est possible de différencier les chiffres des lettres dans une string. Si oui, comment faire? Y'a-t-il une fo
Convertir Chiffres en lettres [ par slim59 ]
Slut. à tous. Comment peut ont faire pour convertir des chiffres en lettres et les imprimer (J'utilise QuickReport). Merci+++
caractere indesirable [ par deubal ]
bonjour,Voila dans mon appli, j'ai un champs contenant le nom d'une entreprise (plusieurs mots ecrits en toutes lettres) saisit par l'utilisateur. je
Chiffres en lettres dans quickreport [ par yaki_5200 ]
Mes remerciments je souhaite une totale reussite pour l'ensemble des contribuables et de l'effort de la diversité de l'aide qu'il offrents partic
Compteur de lettres et mots [ par luke101 ]
Bonjour mesdames zé messieurs, Je suis débutant en Delphi, et j'aimerais réaliser un petit programme (Simple, me disait-on), qui compterait le
Incrémenter un numéro de série [ par 76julien ]
Salut tout le monde, j'ai fait du DELPHI dans mon jeune temps mais je ne sais pas comment peut-on incrémenter un numéro de série contenant des lettres
Gros souci de compréhension avec mon pendu [ par bl4cksun ]
Bonjour à tous je suis nouveau d'aujourd'hui , je suis étudiant en première informatique et le cours de programmation en pascale me pose beaucoup de s
fonction qui calcule le nombre de mots dont le nombre de lettres est strictement superieur a 3 dans une phrase [ par john726 ]
Bonjour a tous,Tous ceux qui pourront m'aider seront les bienvenue...J'aimerai coder une fonction qui calcul
comment ecrire des chiffres en lettres sou access [ par missnour26 ]
Bonjour, Je vous prie de bien vouloir m'aider à résoudre un problème qui me tracasse depuis un certain temps. Comment pouvoir, dans Access, créer une
arrangement (anagramme sans répétition de lettres) [ par jlmcom ]
Y a t-il un delphiman sympa qui a écrit le programme ou l'algorythme pour réaliser tous les arrangements possibles sans répétition (sorte d'anagramme)
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|