小写转大写

Function QtyToChar(Qty: Double): String;
Const
  Con: Array [0 .. 3] Of String[2] = ('', '拾', '佰', '仟');
  DD: Array [0 .. 9] Of String[2] = ('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒',
    '捌', '玖');
Var
  Str: String;
  i, r: Byte;
Begin
  If Qty < 0 Then
    Qty := -Qty;
  Str := FormatFloat('#', Qty * 100);
  Result := '';
  For r := 1 to Length(Str) Do
  Begin
    i := StrToInt(Str[Length(Str) - r + 1]);
    Case r OF
      1:
        Result := DD[i] + '分';
      2:
        Result := DD[i] + '角' + Result;
    Else
      IF i > 0 then
        Result := DD[i] + Con[(r - 3) Mod 4] + Result
      Else
      Begin
        if (Copy(Result, 1, 2) <> '零') Then
          Result := '零' + Result;
      End;
    End;
    IF r < Length(Str) Then
      CASE r OF
        2:
          Result := '元' + Result;
        6:
          Result := '万' + Result;
        10:
          Result := '亿' + Result;
      End;
  End;
  While Pos('零元', Result) > 0 Do
    Delete(Result, Pos('零元', Result), 2);
  While Pos('零万', Result) > 0 Do
    Delete(Result, Pos('零万', Result), 2);
  While Pos('零亿', Result) > 0 Do
    Delete(Result, Pos('零亿', Result), 2);
  Result := Result + '整';
End;

  

posted @ 2015-12-16 11:09  刀小爱  阅读(167)  评论(0编辑  收藏  举报