نمایش نتایج 1 تا 2 از 2

نام تاپیک: نمایش اعداد به حروف

  1. #1
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    ایران
    پست
    101

    نمایش اعداد به حروف

    کسی کامپوننت یا OCX داره که اعداد را به حروف نمایش بده :wink:

  2. #2

    function AliHgethoroof(i:int64):string;
    const v=' و ';
    var
    ok:boolean;
    {___________________________________}
    function yekan(y:byte):string;
    begin
    case y of
    0:result:='';
    1:result:='یک';
    2:result:='دو';
    3:result:='سه';
    4:result:='چهار';
    5:result:='پنج';
    6:result:='شش';
    7:result:='هفت';
    8:result:='هشت';
    9:result:='نه';
    enD;
    if result=''then ok:=false else ok:=true;
    end;
    {___________________________________}
    function dahgan(y:byte):string;
    begin
    case y of
    0:result:='';
    1:result:='ده';
    2:result:='بیست';
    3:result:='سی';
    4:result:='چهل';
    5:result:='پنجاه';
    6:result:='شصت';
    7:result:='هفتاد';
    8:result:='هشتاد';
    9:result:='نود';
    enD;
    if result=''then ok:=false else ok:=true;
    end;
    {___________________________________}
    function sadgan(y:byte):string;
    begin
    case y of
    0:result:='';
    1:result:='یکصد';
    2:result:='دویست';
    3:result:='سیصد';
    4:result:='چهارصد';
    5:result:='پانصد';
    6:result:='ششصد';
    7:result:='هفتصد';
    8:result:='هشتصد';
    9:result:='نهصد';
    enD;
    if result=''then ok:=false else ok:=true;
    end;
    {___________________________________}
    function dah(y:byte):string;
    begin
    case y of
    0:result:='';
    10:result:='ده';
    11:result:='یازده';
    12:result:='دوازده';
    13:result:='سیزده';
    14:result:='چهارده';
    15:result:='پانزده';
    16:result:='شانزده';
    17:result:='هفده';
    18:result:='هجده';
    19:result:='نوزده';
    enD;
    if result=''then ok:=false else ok:=true;
    end;
    {___________________________________}
    function seragham(si:smallint):string;
    begin
    result:='';
    result:=sadgan(si div 100);
    if ok then result:=result+v;

    if((si mod 100)div 10)<>1 then begin
    result:=result+dahgan((si mod 100)div 10);
    if ok then result:=result+v;
    result:=result+yekan(si mod 10);
    if not ok then result:=copy(result,1,length(result&#4 1;-3);
    End
    else begin
    result:=result+dah(si mod 100);
    end;
    if result='' then ok:=false else ok:=true;
    end;
    {___________________________________}
    const
    tr=' تریلیون';
    mr=' میلیارد';
    ml=' میلیون';
    hz=' هزار';
    begin
    ok:=false;

    result:=seragham(i div 1000000000000);
    if ok then result:=result+tr+v;
    result:=result+seragham((i mod 1000000000000)div 1000000000);
    if ok then result:=result+mr+v;
    result:=result+seragham((i mod 1000000000)div 1000000);
    if ok then result:=result+ml+v;
    result:=result+seragham((i mod 1000000)div 1000);
    if ok then result:=result+hz+v;
    result:=result+seragham(i mod 1000);
    if not ok then result:=copy(result,1,length(result&#4 1;-3);

    if i=0 then result:='صفر';
    end;

    این کد رو سعی کردم طوری بنویسم که بعدا اگر نیاز به استفاده از اعداد بزرگتر شد امکان توسعه دادنش باشه.
    پیروز باشید.

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •