begin process at 2010 02 10 08:17:35
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Texte

 > CONVERTION DE CHIFFRES EN LETTRES

CONVERTION DE CHIFFRES EN LETTRES


 Information sur la source

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Texte Classé sous :conversion, chiffres, lettres, mots Niveau :Initié Date de création :24/10/2005 Date de mise à jour :26/10/2005 00:36:08 Vu / téléchargé :14 336 / 903

Auteur : sagit_terre

Ecrire un message privé
Commentaire sur cette source (6)
Ajouter un commentaire et/ou une note

 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

Les Membres Club peuvent 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

Source avec Zip COMBINAISONS DE STRINGS par askil2000
Source avec Zip Source avec une capture RECONNAISSANCE DE CARACTÈRES (OCR) par Bacterius
Source avec Zip Source avec une capture NETTOYAGE AUTOMATIQUE DE NOMS DE FICHIERS par John Dogget
DISTANCE DE JARO-WINKLER par PoulpHunter
Source avec Zip BASE DE DONNÉE WIKI par thithony

 Sources en rapport avec celle ci

Source avec Zip JEU RAMI DES CHIFFRES SOLITAIRE par Toidil
Source avec Zip Source avec une capture UN RAMI AVEC DES LETTRES par Debiars
CONVERSION D'UN NOMBRE COMPRIS 0 ET 999999999999999999 (18 C... par Hror
Source avec Zip Source avec une capture CONVERSION DE TEMPERATURE par noch100
Source avec Zip Source avec une capture JEU DE CHIFFRES par kilanihalim

Commentaires et avis

Commentaire de blanc76 le 29/10/2005 20:33:33

Bien mais votre source est trop long, tu as déclaré de zéro à cent, tu peut utilisé la concaténtion des chaines pour l'éviter.
Tu peut consulter :
http://www.delphifr.com/code.aspx?ID=32519
Bonne prog.

Commentaire de kam_2006 le 13/01/2006 20:25:06

Bonsoir

C'est code n'est pas mal

Commentaire de jackalunion le 22/06/2008 12:49:05 10/10

trés bien

Commentaire de kimlion1 le 09/01/2009 15:29:02

merci c du nouveau comme même
merci

Commentaire de kachwahed le 05/12/2009 13:16:52

Très bon travail, merci pour le code, voire aussi:
http://www.fobec.com/protec/grenier2/encadre.php3?cat=VDivers&id_log=60
par: Jean Jamet
et:
http://www.phidels.com/php/index.php3?page=../php/pagetelechargementzip.php3&id=242&PHPSESSID=f2c953407e61f5c4eeae850c98d6f34b
par: Amar Guessas

Commentaire de kachwahed le 05/12/2009 13:19:28

Il y a aussi une bonne fonction sur developez.com:
http://delphi.developpez.com/faq/?page=typenombre#nombreenlettres
J'ai enlever le paramètre "France: boolean" ici:
function NombreEnLettres(n : integer) : string;
Const
  unite   : array[1..19] of string = ('un','deux','trois','quatre','cinq','six',
                                      'sept','huit','neuf','dix','onze','douze',
                                      'treize','quatorze','quinze','seize',
                                      'dix sept','dix huit','dix neuf');
  dizaineF: array[2.. 9] of string = ('vingt','trente','quarante','cinquante',
                                     'soixante','','quatre-vingt','');
  dizaineB: array[2.. 9] of string = ('vingt','trente','quarante','cinquante',
                                     'soixante','septante','octante','nonante');
  coefs   : array[0.. 3] of string = ('cent','mille','million','milliard');
Var
  temp    : String;
  c, d, u : Integer;
  coef    : Integer;
  i       : Integer;
  neg     : boolean;
Begin
  result := '';

  // Cas particulier de zéro
  If n = 0 then
  begin
    result := ' zero';
    exit;
  end;

  // Mémorisation du signe
  neg := n < 0;
  If neg then n := -n;

  coef:=0;
  Repeat
    // Récupération de l'unité du bloc de trois chiffres en cours
    u:=n mod 10; n:=n div 10;
    // Récupération de la dizaine du bloc de trois chiffres en cours
    d:=n mod 10; n:=n div 10;

    // Traitement des dizaines
    temp := '';
    // Passage sur la dizaine inférieure pour 10 à 19
    // et pour 70-79 90-99 dans le cas de la France
    If (d=1) Or ((d in [7,9])) then
    begin
      Dec(d);
      Inc(u,10);
    end;
    if d > 1 then
    begin
        temp := ' ' + DizaineF[d];
        // Ajout du cas particulier de 'et' entre la dizaine et 1
        if (d < 8) and ((u = 1) or (u = 11)) then
          temp := temp + ' et';
    end;
    // ajout du texte de l'unité
    if u > 0 then temp := temp + ' ' + unite[u];
    // ajout du 's' à Quatre-vingt si rien ne suit
    If (result = '') and (d = 8) and (u = 0) then result := 's';
    result := temp + result;

    // Récupération de la centaine du bloc de trois chiffres en cours
    c := n mod 10; n := n div 10; {Récupère centaine}
    If c > 0 then
    begin
      temp := '';
      if c > 1 then temp := ' ' + unite[c] + temp;
      temp := temp + ' ' + coefs[0];
      // Traitement du cas particulier du 's' à cent si rien ne suit
      If (result = '') and (c > 1) then result := 's';
      result := temp + result;
    end;

    // Traitement du prochain groupe de 3 chiffres
    if n > 0 then
    begin
      Inc(coef);
      I := n mod 1000;
      If (i > 1) and (coef > 1) then result := 's' + result;
      If i > 0 then result := ' ' + coefs[coef] + result;
      // Traitement du cas particulier 'mille' ( non pas 'un mille' )
      If (i = 1) and (coef = 1) then Dec(n);
    end;
  until n = 0;
  result := Trim(result);

  // Ajout du signe en cas de besoin
  if neg then result := 'moins ' + result;
End;

 Ajouter un commentaire


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&#233; 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 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 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 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)


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,640 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales