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

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

Threaded View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #7
    VIP آواتار دنیای دلفی
    تاریخ عضویت
    تیر 1404
    محل زندگی
    یک جایی توی جنوب ایران
    پست
    1,298
    من از کد زیر برای تبدیل عدد به متن استفاده می کنم ولی عکسش را چیکار کنم

    unit Curr2Str;
    interface
    function Add2Harf(i:int64):string;
    implementation
    function Add2Harf(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)-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)-3);
    if i=0 then result:='صفر';
    end;




    end.

    آخرین ویرایش به وسیله دنیای دلفی : شنبه 19 فروردین 1385 در 13:27 عصر

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

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