我都不懂得英文的货币怎样写,怎样能做出来啊。哪位大哥已经做出来了,共享一下吧。

解决方案 »

  1.   

    收藏的,参考一下{**************************************************} 
    {                                                  } 
    {  Number to letters unit version 1.1              } 
    {                                                  } 
    {  copyright (C) Dylan Thomas 2000                 } 
    {                                                  } 
    {  License: No significant restrictions.           } 
    {                                                  } 
    {  Language: US. English                           } 
    {                                                  } 
    {**************************************************} unit NumberToLetters; interface {var   Calls: Integer;} //Use to count number of recursive calls (* This function returns the written equivalent of a number. *) 
    function NumToLetters(Number: Real): string; implementation 
    uses SysUtils; type   TNumberStr = string[13]; const 
      Numbers: array[1..19] of TNumberStr = ('one', 'two', 'three', 'four', 
        'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 
        'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 
        'nineteen');   Tenths: array[1..9] of TNumberStr = ('ten', 'twenty', 'thirty', 'forty', 
        'fifty', 'sixty', 'seventy', 'eighty', 'ninety');   ErrorString = 'not in valid range';   Min = 1.00; 
      Max = 4294967295.99; function NumToLetters(Number: Real): string;   function RecurseNumber(N: LongWord): string; 
      begin 
        {Inc(Calls);} //Use to count the number of recursive calls 
        case N of 
          1..19: 
            Result := Numbers[N]; 
          20..99: 
            Result := Tenths[N div 10] + ' ' + RecurseNumber(N mod 10); 
          100..999: 
            Result := Numbers[N div 100] + ' hundred ' + RecurseNumber(N mod 100); 
          1000..999999: 
            Result := RecurseNumber(N div 1000) + ' thousand ' + 
              RecurseNumber(N mod 1000); 
          1000000..999999999: Result := RecurseNumber(N div 1000000) + ' million ' 
            + RecurseNumber(N mod 1000000); 
          1000000000..4294967295: Result := RecurseNumber(N div 1000000000) + 
            ' billion ' + RecurseNumber(N mod 1000000000); 
        end; {Case N of} 
      end; {RecurseNumber} begin 
      {Calls := 0;} //Use to count the number of recursive calls 
      if (Number >= Min) and (Number <= Max) then 
        begin 
          Result := RecurseNumber(Round(Int(Number))); 
          {Added for cents in a currency value} 
          if not(Frac(Number) = 0.00) then 
            Result := Result +  ' and ' + IntToStr(Round(Frac(Number) * 100)) + 
              '/100'; 
        end 
      else 
        raise ERangeError.CreateFmt('%g ' + ErrorString + ' %g..%g', 
          [Number, Min, Max]); 
    end;{NumToLetters} end.
      

  2.   

    在delphi编程资源大全光盘上有源代码!
      

  3.   

    数字转英文大写。
    unit U_MoneyToENUpper;interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,StrUtils;function DigitToEn(strDigits: String; intRMB: Boolean): String;
    //function DigitToEn2(strDigits: String): String;
    //function DigitToEn3(strDigits: String; intFormat: Integer): String;implementation//将在0.01-99,999999.99之间的数字转换成英文表示法
    //调用本Function时,strDigits不可包含千位分隔符,并且小数部分要保留两位,如果有的话。
    function DigitToEn(strDigits: String; intRMB: Boolean): String;
      //将在1-19之间的数字转换成英文表示法
      function DigitToEn1(strDigits: String): String;
      begin
        Case StrToInt(strDigits) of
          1: Result := 'ONE';
          2: Result := 'TWO';
          3: Result := 'THREE';
          4: Result := 'FOUR';
          5: Result := 'FIVE';
          6: Result := 'SIX';
          7: Result := 'SEVEN';
          8: Result := 'EIGHT';
          9: Result := 'NINE';
          10: Result := 'TEN';
          11: Result := 'ELEVEN';
          12: Result := 'TWELVE';
          13: Result := 'THIRTEEN';
          14: Result := 'FOURTEEN';
          15: Result := 'FifTEEN';
          16: Result := 'SIXTEEN';
          17: Result := 'SEVENTEEN';
          18: Result := 'EIGHTEEN';
          19: Result := 'NINETEEN';
        else
          Result := '';
        end;
      end;
      //将在1-99之间的数字转换成英文表示法
      function DigitToEn2(strDigits: String): String;
      var
        strTemp: String;
      begin
        if StrToInt(strDigits) < 20 then
          Result := DigitToEn1(strDigits)
        else begin
          Case StrToInt(leftstr(strDigits, 1)) of
            2: strTemp := 'TWENTY';
            3: strTemp := 'THIRTY';
            4: strTemp := 'FORTY';
            5: strTemp := 'FIFTY';
            6: strTemp := 'SIXTY';
            7: strTemp := 'SEVENTY';
            8: strTemp := 'EIGHTY';
            9: strTemp := 'NINETY';
          else
            strTemp := '';
          end;
          
          if Rightstr(strDigits, 1) <> '0' then
              strTemp := strTemp + '-' + DigitToEn1(Rightstr(strDigits, 1));      Result := strTemp;
        end;
      end;
      //将在1-999之间的数字转换成英文表示法
      //如intFormat为1,则在HUNDRED 后面就有 AND,否则没有。
      function DigitToEn3(strDigits: String; intFormat: Integer): String;
      begin
        //去掉数字串前面的0
        strDigits := IntToStr(StrToInt(strDigits));    if StrToFloat(strDigits) <= 19 then
          Result := DigitToEn1(strDigits)
        else if (StrToFloat(strDigits) >= 20) and (StrToFloat(strDigits) <= 99) then
          Result := DigitToEn2(strDigits)
        else begin
          Result := DigitToEn1(Leftstr(strDigits, 1)) + ' HUNDRED';
          if (StrToFloat(Rightstr(strDigits, 2)) > 0) and
            (StrToFloat(Rightstr(strDigits, 2)) < 20) then
            if intFormat = 1 then
              Result := Result + ' AND ' + DigitToEn1(Rightstr(strDigits, 2))
            else
              Result := Result + ' ' + DigitToEn1(Rightstr(strDigits, 2))
          else if (StrToFloat(Rightstr(strDigits, 2)) >= 20)
            and (StrToFloat(Rightstr(strDigits, 2)) <= 99) then
            if intFormat = 1 then
              Result := Result + ' AND ' + DigitToEn2(Rightstr(strDigits, 2))
            else
              Result := Result + ' ' + DigitToEn2(Rightstr(strDigits, 2));
        end;
      end;var
      // 整数部份 小数部份
      strInteger, strDecimal: String;
      strTemp: String;
    begin
      if (StrToFloat(strDigits) > 9999999999.99) or
        (StrToFloat(strDigits) < 0.01) then
        raise exception.Create('Out of range, must between 0.01 - 9999999999.99');  //有整数部分及小数部分
      if (Int(StrToFloat(strDigits)) > 0) and
        (StrToFloat(strDigits) - Int(StrToFloat(strDigits)) > 0) then
      begin
        strInteger := Leftstr(strDigits, Pos('.', strDigits) - 1);
        strDecimal := Rightstr(strDigits, Length(strDigits) - Pos('.', strDigits));
      end
      //只有整数部分
      else if Int(StrToFloat(strDigits)) > 0 then
        strInteger := IntToStr(Round(StrToFloat(strDigits)))
      //只有小数部分
      else if StrToFloat(strDigits) - Int(StrToFloat(strDigits)) > 0 then
        strDecimal := Rightstr(strDigits, Length(strDigits) - Pos('.', strDigits));  //得到整数部分英文表示法
      if strInteger <> '' then begin
        strTemp := DigitToEn3(Rightstr(strInteger, 3), 1);
        if Length(strInteger) > 3 then begin
          strTemp := DigitToEn3(Leftstr(Rightstr(strInteger, 6),
            Length(Rightstr(strInteger, 6)) - 3), 2) + ' THOUSAND ' + strTemp;
          if Length(strInteger) > 6 then
            strTemp := DigitToEn3(Leftstr(strInteger, Length(strInteger) - 6), 2) +
            ' MILLION ' + strTemp;
        end;
        strInteger := strTemp;
      end;  if (strDecimal <> '') and (Length(strDecimal) <= 3) then
        strDecimal := DigitToEn3(strDecimal, 1);  if (strInteger <> '') and (strDecimal <> '') then
        if intRMB then
          Result := strInteger + ' YUANS AND ' + strDecimal + ' CENTS ONLY'
        else
          Result := strInteger + ' DOLLARS AND ' + strDecimal + ' CENTS ONLY'
      else if strInteger <> '' then
        if intRMB then
          Result := strInteger + ' YUANS ONLY'
        else
          Result := strInteger + ' DOLLARS ONLY'
      else if strDecimal <> '' then
        Result := strDecimal + ' CENTS ONLY'
      else
        Result := 'ZERO';
    end;
    end.
      

  4.   

    英文中,小数后的是不是那样表示?上面那段代码就是那样的。而且不能转换小于1的。540425.25five hundred forty  thousand four hundred twenty five and 25/100
      

  5.   

    给你一个我写的函数!type
      TMyTable=record
        iDigital:integer;
        sName:string;
    end;function ConvertSliceUSA(Input:string;Length:integer;Table:array of TMyTable):string;//是对每三位的一个转换
    function ConvertDigitalUSA(Input:string):string; //是真正的小写到英文大写的转换函数。
    function ConvertMoneyUSA(Input,currency:string):string; //是调用ConvertDigitalUSA转换货币
    function ConvertSliceUSA(Input:string;Length:integer;Table:array of TMyTable):string;
    const
      TYTable:array [0..7] of TMyTable =
        ((idigital:2;sname:'TWENTY'),
         (idigital:3;sname:'THIRTY'),
         (idigital:4;sname:'FORTY'),
         (idigital:5;sname:'FIFTY'),
         (idigital:6;sname:'SIXTY'),
         (idigital:7;sname:'SEVENTY'),
         (idigital:8;sname:'EIGHTY'),
         (idigital:9;sname:'NINETY')
        );
    var
      CurDigital: integer;
      counter,temp: integer;
    begin
      result := '';
      if Length = 3 then  //have hundred bit
        begin
          CurDigital := strtoint(copy(Input,1,1));  //get hundred bit
          Input := copy(Input,2,2);
          for counter := 0 to 9 do
            if Table[counter].iDigital = CurDigital then
              begin
               { if CurDigital > 1 then  //adjust the unit name for plural
                  begin
                    result := result + Table[counter].Name+' HUNDREDS';
                    if strtoint(Input) <> 0 then
                      result := result + ' AND '
                    else
                      exit;
                  end
                else
                  begin}
                    result := result + Table[counter].sName+' HUNDRED';
                    if strtoint(Input) <> 0 then
                      result := result + ' AND '
                    else
                      exit;
                //  end;
                break;
              end;
        end;
      temp := strtoint(Input);
      for counter := 0 to 18 do
        if Table[counter].iDigital = temp then //the digital less than 20
          begin
            result := result + Table[counter].sName;
            exit;
          end;  //the digital more than 20
      temp := strtoint(copy(Input,1,1)); //get the tens bit
      for counter := 0 to 7 do
        if TYTable[counter].iDigital = temp then
          begin
            result := result + TYTable[counter].sName+' ';
            break;
          end;  //set the last bit value
      temp := strtoint(copy(Input,2,1));
      if temp = 0 then
        exit;
      for counter := 0 to 8 do
        if Table[counter].iDigital = temp then
          begin
            result := result + Table[counter].sName;
            break;
          end;
    end;//输入一个整数部分不超过12位的实数,将其转化为大写。function ConvertDigitalUSA(Input:string):string;
    const
      MAXLENGTH = 12;   //Max length of input string
      BaseTable:array [0..18] of TMyTable =
        ((idigital:1;sname:'ONE'),
         (idigital:2;sname:'TWO'),
         (idigital:3;sname:'THREE'),
         (idigital:4;sname:'FOUR'),
         (idigital:5;sname:'FIVE'),
         (idigital:6;sname:'SIX'),
         (idigital:7;sname:'SEVEN'),
         (idigital:8;sname:'EIGHT'),
         (idigital:9;sname:'NINE'),
         (idigital:10;sname:'TEN'),
         (idigital:11;sname:'ELEVEN'),
         (idigital:12;sname:'TWELVE'),
         (idigital:13;sname:'THIRTEEN'),
         (idigital:14;sname:'FOURTEEN'),
         (idigital:15;sname:'FIFTEEN'),
         (idigital:16;sname:'SIXTEEN'),
         (idigital:17;sname:'SEVENTEEN'),
         (idigital:18;sname:'EIGHTEEN'),
         (idigital:19;sname:'NINETEEN')
        );
      UnitName: array [0..3] of string =
        ('HUNDRED','THOUSAND','MILLION','BILLION');
    var
      PointLocation,DigitalLength: integer;
      CurLength: integer;
      int,dec,CurUnitName: string;
      buffer:string;
    begin
      CurLength := 0;  try
        strtofloat(Input);
      except
          ShowMessage('数据类型错误!');
        exit;
      end;  //seperate a real number to two parts as integer and decimal
      PointLocation := pos('.',Input);
      if PointLocation = 0 then  //no decimal
        int := Input
      else
        begin
          int := copy(Input,1,PointLocation-1);
          dec := copy(Input,PointLocation+1,2);
        end;  DigitalLength := Length(int);
      if DigitalLength > MAXLENGTH then
        begin
          Showmessage('输入数据位数超过转换能力!');
          exit;
        end;  //convert the integer
      while DigitalLength >0 do
        begin
          CurUnitName := UnitName[(DigitalLength-1) div 3]; //set current unit name
          case DigitalLength of
            12,11,10: CurLength := DigitalLength - 9;
               9,8,7: CurLength := DigitalLength - 6;
               6,5,4: CurLength := DigitalLength - 3;
               3,2,1: CurLength := DigitalLength;
          end;
          if DigitalLength > 3 then //digital more than 1000
            begin
              buffer := copy(int,1,CurLength); //get slice of integer for deal
              if strtoint(buffer) > 1 then     //adjust the unit name for plural
                CurUnitName := CurUnitName + 'S';
              result := result + ConvertSliceUSA(buffer,CurLength,BaseTable);
              result := result + ' ' + CurUnitName + ' ';
            end
          else  //digital less than 1000
            result := result + ConvertSliceUSA(int,length(int),BaseTable);      //reset the decimal
          DigitalLength := DigitalLength-CurLength;
          int := copy(int,CurLength+1,DigitalLength);
        end;  if (dec <> '') and (strtoint(dec) <> 0) then
        result := result+' AND '+inttostr(strtoint(dec))+'/100';
    end;
    function ConvertMoneyUSA(Input,currency:string):string;
    begin
      result := 'SAY '+Trim(currency)+' '+ConvertDigitalUSA(Input)+' ONLY';
    end;