![]() |
|
مشكل في برنامج تحويل الارقام الى حروف - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15) +--- الموضوع : مشكل في برنامج تحويل الارقام الى حروف (/showthread.php?tid=12191) |
مشكل في برنامج تحويل الارقام الى حروف - salah07230 - 24-01-2023 عندي هذا البرنامج يحول الارقام الى حروف لكن فيه مشكلة مثلا عند كتابة الرقم: 565.55 يعطيني النتيجة: Cinq Cent Soixante Cinq Dinars et Cinquante Quatre CTS وهي خاطئة فهل تكرمتم بتصحيح البرنامج وشكرا. السورس كود: كود : nit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
SpeedButton1: TSpeedButton;
Label1: TLabel;
Memo1: TMemo;
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var chaine:string;
p,nombre,q,DEC:integer;
N,n1:real;
procedure decimale(var p3:integer);
begin
if p3=10 then chaine:=chaine+ ' Dix';
if p3=11 then chaine:=chaine+ ' Onze';
if p3=12 then chaine:=chaine+ ' Douze';
if p3=13 then chaine:=chaine+ ' Treize';
if p3=14 then chaine:=chaine+ ' Quatorze';
if p3=15 then chaine:=chaine+ ' Quinze';
if p3=16 then chaine:=chaine+ ' Seize';
if p3=17 then chaine:=chaine+ ' Dix Sept';
if p3=18 then chaine:=chaine+ ' Dix Huit';
if p3=19 then chaine:=chaine+ ' Dix Neuf';
end;
procedure chiffre(var p2:integer);
begin
if p2=1 then chaine:=chaine+ ' Un';
if p2=2 then chaine:=chaine+ ' Deux';
if p2=3 then chaine:=chaine+ ' Trois';
if p2=4 then chaine:=chaine+ ' Quatre';
if p2=5 then chaine:=chaine+ ' Cinq';
if p2=6 then chaine:=chaine+ ' Six';
if p2=7 then chaine:=chaine+ ' Sept';
if p2=8 then chaine:=chaine+ ' Huit';
if p2=9 then chaine:=chaine+ ' Neuf';
end;
procedure mille(var p1:integer);
var c:integer;
begin
c:=p1 div 100;
if c=1 then chaine:=chaine+ ' Cent';
if c=2 then chaine:=chaine+ ' Deux Cent';
if c=3 then chaine:=chaine+ ' Trois Cent';
if c=4 then chaine:=chaine+ ' Quatre Cent';
if c=5 then chaine:=chaine+ ' Cinq Cent';
if c=6 then chaine:=chaine+ ' Six Cent';
if c=7 then chaine:=chaine+ ' Sept Cent';
if c=8 then chaine:=chaine+ ' Huit Cent';
if c=9 then chaine:=chaine+ ' Neuf Cent';
p1:=p1-c*100; c:=p1 div 10;
if c=2 then begin chaine:=chaine+ ' Vingt';
p1:=p1-c*10; chiffre(p1);
end;
if c=3 then
begin
chaine:=chaine+ ' Trente';
p1:=p1-c*10;
chiffre(p1);
end;
if c=4 then
begin
chaine := chaine+ ' Quarante';
p1:=p1-c*10;
chiffre(p1);
end;
if c=5 then
begin
chaine:=chaine+ ' Cinquante';
p1:=p1-c*10;
chiffre(p1);
end;
if c=6 then
begin
chaine:=chaine+ ' Soixante';
p1:=p1-c*10;
chiffre(p1);
end;
if c=8 then
begin
chaine:=chaine+ ' Quatre Vingt';
p1:=p1-c*10;
chiffre(p1);
end;
if c=0 then chiffre(p1);
if c=1 then decimale(p1);
if c=7 then
begin
chaine := chaine+ ' Soixante';
p1:=p-60;
decimale(p1);
end;
if c=9 then
begin
chaine:=chaine+ ' Quatre Vingt';
p1:=p1-80;
decimale(p1);
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var abc:real;
begin
memo1.Clear;
if edit1.Text='' then Abort;
chaine:='';
n:= StrToFloat(edit1.Text);
nombre:=trunc(n);
abc:=int(n*100);
dec:=trunc(abc) mod 100;
if nombre>=1000000000 then
begin
p := nombre div 1000000000;
nombre:= nombre - p * 1000000000;
if p<>0 then
begin
mille(p);
chaine:=chaine+ ' Milliard';
end;
end;
//---------{milliards}---------------------
if nombre>=1000000 then
begin
p := nombre div 1000000;
nombre := nombre - p * 1000000;
if p<>0 then
begin
mille(p);
chaine:=chaine+ ' Million';
end;
end;
//---------{milliers}---------------------
if nombre>=1000 then
begin
p := nombre div 1000;
nombre := nombre - p * 1000;
if p<>1 then
begin
mille(p);
chaine := chaine + ' Mille';
end else
chaine := chaine + 'mille';
end;
//---------{simple}---------------------
if (0<=nombre) and (nombre<1000) then
begin
p := nombre;
mille(p);
end;
chaine:=chaine+ ' Dinars' +' et';
begin
q:=dec; mille(q);
IF q=0 THEN chaine := chaine+ ' Zero CTS'
Else chaine := chaine+ ' CTS'
end;
//---------{chaine:=chaine+ ' dinars' +' et'+chaine1+' CTS';}--------
// memo1.Text:= chaine;
memo1.Lines.Add('');
memo1.Lines.Add(chaine);
end;
end. |