⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commonuse.pas

📁 Delphi的很有用的常用的方法和函数列表.
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87,   //2014
    $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87,   //2015
    $95, $B4, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86,   //2016
    $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87,   //2017
    $A5, $B4, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87,   //2018
    $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87,   //2019
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $86,   //2020
    $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86,   //2021
    $A5, $B4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87,   //2022
    $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87,   //2023
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96,   //2024
    $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86,   //2025
    $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87,   //2026
    $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87,   //2027
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96,   //2028
    $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86,   //2029
    $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87,   //2030
    $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87,   //2031
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96,   //2032
    $A5, $C3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $86,   //2033
    $A5, $B3, $A5, $A5, $A6, $A6, $88, $78, $88, $78, $87, $87,   //2034
    $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87,   //2035
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96,   //2036
    $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86,   //2037
    $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87,   //2038
    $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87,   //2039
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96,   //2040
    $A5, $C3, $A5, $B5, $A5, $A6, $87, $88, $87, $78, $87, $86,   //2041
    $A5, $B3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87,   //2042
    $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87,   //2043
    $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $88, $87, $96,   //2044
    $A5, $C3, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86,   //2045
    $A5, $B3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87,   //2046
    $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87,   //2047
    $95, $B4, $A5, $B4, $A5, $A5, $97, $87, $87, $88, $86, $96,   //2048
    $A4, $C3, $A5, $A5, $A5, $A6, $97, $87, $87, $78, $87, $86,   //2049
    $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $78, $78, $87, $87);  //2050

Function SmallToBig5(Const aNumber: Double): String;
Var 
  i, j: Integer;    //转换出数量汉字大写字符串
  zheng: Integer;
  ch, LowerSL: String;
  A: Array[1..10] Of String;
  B: Array[1..13] Of String;
Begin
  LowerSL := FloatToStr(aNumber);
  A[1] := '壹';
  A[2] := '贰';
  a[3] := '叁';
  a[4] := '肆';
  a[5] := '伍';
  a[6] := '陆';
  A[7] := '柒';
  A[8] := ' 捌';
  A[9] := '玖';
  A[10] := '拾';
  b[1] := '';
  b[2] := '拾';
  b[3] := '佰';
  B[4] := '仟';
  b[5] := '万';
  b[6] := '拾万';
  b[7] := '佰万';
  b[8] := '仟万';
  b[9] := '亿';
  b[10] := '拾亿';
  b[11] := '佰亿';
  b[12] := '仟亿';
  b[13] := '';
  zheng := Length(LowerSL) + 1;
  i := length(IntToStr(trunc(strtofloat(LowerSL)))) + 1;
  If LowerSL[1] = '.' Then 
  Begin 
    ch := ch + '零'; 
    j := 1;
    If (zheng > i) And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
      ch := ch + '点';
    If zheng > i Then
      For j := j + 1 To zheng - 1 Do
        If (LowerSL[j] = '0') And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
          ch := ch + '零'
      Else
        ch := ch + a[StrToInt(LowerSL[j])];
  End 
  Else 
  Begin
    If (trunc(strtofloat(LowerSL)) = 0) And (zheng = i) Then
      ch := ch + '零'
    Else
      For j := 1 To i - 1 Do
        If (LowerSL[j] = '0') And (LowerSL[j + 1] = '0') Then 
        Begin
          continue;
        End 
      Else If (LowerSL[j] = '0') And (LowerSL[j + 1] <> '0') And         //
        (LowerSL[j + 1] <> '') And (LowerSL[j + 1] <> '.') Then
        // 这三行是处理中间的零。
        ch := ch + a[StrToInt(LowerSL[j])] + '零'                   //
      Else If (i = 2) And (LowerSL[j] = '0') And (LowerSL[j + 1] = '.') Then
        ch := ch + '零'                                            //判断是否是小数。
      Else If (i - j = 6) And (LowerSL[j + 1] <> '0') Then  //判断是否是十万位
        ch := ch + a[StrToInt(LowerSL[j])] + '拾'
      Else If (i - j = 7) And (LowerSL[j + 1] <> '0') Then
        ch := ch + a[StrToInt(LowerSL[j])] + '佰' //判断是否是佰万位
      Else If (i - j = 8) And (LowerSL[j + 1] <> '0') Then
        ch := ch + a[StrToInt(LowerSL[j])] + '仟' //判断是否是仟万位
      Else If (i - j = 10) And (LowerSL[j + 1] <> '0') Then
        ch := ch + a[StrToInt(LowerSL[j])] + '拾'     //判断是否是十亿位
      Else If (i - j = 11) And (LowerSL[j + 1] <> '0') Then
        ch := ch + a[StrToInt(LowerSL[j])] + '佰'    //判断是否是佰亿位
      Else If (i - j = 12) And (LowerSL[j + 1] <> '0') Then
        ch := ch + a[StrToInt(LowerSL[j])] + '仟'   //判断是否是仟亿位
      Else
        ch := ch + A[StrToInt(LowerSL[j])] + b[I - j];
    If (zheng > i) And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
      ch := ch + '点';
    If zheng > i Then
      For j := j + 1 To zheng - 1 Do
        If (LowerSL[j] = '0') And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
          ch := ch + '零'
      Else
        ch := ch + a[StrToInt(LowerSL[j])];
  End;
  Result := '';
  Result := ch;
End;

Function SmallToBig4(Const rmbSmall: Currency): String;
Var
  NumStr: Array[1..10] Of String;               //汉字大写的数字
  Sign: Array[1..12] Of String;                 //汉字大写的单位
  IntPart,                                    //整数部分
  RealPart,                                   //小数部分
  UpperMoney, LowerMoney: String;
  i, j: Integer;                               //循环变量
Begin
  //开始初始化数组
  LowerMoney := FloatToStr(rmbSmall);
  NumStr[1] := '零';  
  NumStr[2] := '壹';  
  NumStr[3] := '贰';
  NumStr[4] := '叁';  
  NumStr[5] := '肆';  
  NumStr[6] := '伍';
  NumStr[7] := '陆';  
  NumStr[8] := '柒';  
  NumStr[9] := '捌';
  NumStr[10] := '玖';
  Sign[1] := '元'; 
  Sign[2] := '拾'; 
  Sign[3] := '佰'; 
  Sign[4] := '仟';
  Sign[5] := '万'; 
  Sign[6] := '拾'; 
  Sign[7] := '佰'; 
  Sign[8] := '仟';
  Sign[9] := '亿'; 
  Sign[10] := '拾'; 
  Sign[11] := '佰'; 
  Sign[12] := '仟';
  //初始化数组结束,开始初始化字符串
  IntPart := '';  
  RealPart := '';  
  UpperMoney := '';

  //初始化字符串结束,开始给字符串赋值
  IntPart := FloatToStr(Int(StrToFloat(LowerMoney)));
  RealPart := FloatToStr(Frac(StrToFloat(LowerMoney)));
  //字符串赋值结束,开始数字和汉字转换
  j := 1;
  For i := Length(IntPart) Downto 1 Do 
  Begin
    UpperMoney := NumStr[StrToInt(IntPart[i]) + 1] + Sign[j] + UpperMoney;
    j := j + 1;
  End;
  //结束数字和汉字的转换,开始去掉多余的 0
  If Length(IntPart) >= 2 Then                     //当是二位数时...
    If (IntPart[Length(IntPart)] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 2] := ' ';
      UpperMoney[Length(UpperMoney) - 3] := ' ';
    End;

  If Length(IntPart) >= 3 Then                     //当是三位数时...
    If (IntPart[Length(IntPart) - 1] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 4] := ' ';
      UpperMoney[Length(UpperMoney) - 5] := ' ';
      If (IntPart[Length(IntPart)] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 6] := ' ';
        UpperMoney[Length(UpperMoney) - 7] := ' ';
      End;
    End;

  If Length(IntPart) >= 4 Then                     //当是四位数时...
    If (IntPart[Length(IntPart) - 2] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 8] := ' ';
      UpperMoney[Length(UpperMoney) - 9] := ' ';
      If (IntPart[Length(IntPart) - 1] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 10] := ' ';
        UpperMoney[Length(UpperMoney) - 11] := ' ';
      End;
    End;

  If Length(IntPart) >= 5 Then                     //当是五位数时...
    If (IntPart[Length(IntPart) - 3] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 12] := ' ';
      UpperMoney[Length(UpperMoney) - 13] := ' ';
      If (IntPart[Length(IntPart) - 2] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 14] := ' ';
        UpperMoney[Length(UpperMoney) - 15] := ' ';
      End;
    End;

  If Length(IntPart) >= 6 Then                     //当是六位数时...
    If (IntPart[Length(IntPart) - 4] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 18] := ' ';
      UpperMoney[Length(UpperMoney) - 19] := ' ';
      If (IntPart[Length(IntPart) - 3] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 13] := ' ';
        UpperMoney[Length(UpperMoney) - 14] := ' ';
      End;
    End;

  If Length(IntPart) >= 7 Then                     //当是七位数时...
    If (IntPart[Length(IntPart) - 5] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 20] := ' ';
      UpperMoney[Length(UpperMoney) - 21] := ' ';
      If (IntPart[Length(IntPart) - 4] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 18] := ' ';
        UpperMoney[Length(UpperMoney) - 19] := ' ';
        UpperMoney[Length(UpperMoney) - 22] := ' ';
        UpperMoney[Length(UpperMoney) - 23] := ' ';
      End;
    End;
  If Length(IntPart) >= 8 Then                     //当是八位数时...
    If (IntPart[Length(IntPart) - 6] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 24] := ' ';
      UpperMoney[Length(UpperMoney) - 25] := ' ';
      If (IntPart[Length(IntPart) - 5] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 20] := ' ';
        UpperMoney[Length(UpperMoney) - 21] := ' ';
        UpperMoney[Length(UpperMoney) - 22] := ' ';
        UpperMoney[Length(UpperMoney) - 23] := ' ';
        If (IntPart[Length(IntPart) - 4] = '0') Then 
        Begin
          UpperMoney[Length(UpperMoney) - 18] := ' ';
          UpperMoney[Length(UpperMoney) - 19] := ' ';
          UpperMoney[Length(UpperMoney) - 26] := ' ';
          UpperMoney[Length(UpperMoney) - 27] := ' ';
        End;
      End;
    End;

  If Length(IntPart) >= 9 Then                     //当是九位数时...
    If (IntPart[Length(IntPart) - 7] = '0') Then 
    Begin
      UpperMoney[Length(UpperMoney) - 28] := ' ';
      UpperMoney[Length(UpperMoney) - 29] := ' ';
      If (IntPart[Length(IntPart) - 6] = '0') Then 
      Begin
        UpperMoney[Length(UpperMoney) - 24] := ' ';
        UpperMoney[Length(UpperMoney) - 25] := ' ';
        UpperMoney[Length(UpperMoney) - 26] := ' ';
        UpperMoney[Length(UpperMoney) - 27] := ' ';
        UpperMoney[Length(UpperMoney) - 28] := ' ';
        UpperMoney[Length(UpperMoney) - 29] := ' ';
        UpperMoney[Length(UpperMoney) - 30] := ' ';
        UpperMoney[Length(UpperMoney) - 31] := ' ';
      End;
    End;
  //结束去掉多余的 0 ,开始转换小数部分
  If Length(RealPart) = 1 Then
    UpperMoney := UpperMoney + '整';
  If Length(RealPart) = 3 Then 
  Begin
    If IntPart[Length(IntPart)] = '0' Then
      UpperMoney := UpperMoney + '零';
    UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[3]) + 1] + '角整';
  End;

  If Length(RealPart) >= 4 Then 
  Begin
    If RealPart[3] = '0' Then 
    Begin
      UpperMoney := UpperMoney + '零';
      If RealPart[4] = '0' Then 
      Begin
        UpperMoney[Length(UpperMoney)] := ' ';
        UpperMoney[Length(UpperMoney) - 1] := ' ';
      End 
      Else
        UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[4]) + 1] + '分';
    End;
    If RealPart[3] <> '0' Then 
    Begin
      If IntPart[Length(IntPart)] = '0' Then
        UpperMoney := UpperMoney + '零';
      UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[3]) + 1] + '角';
      If RealPart[4] <> '0' Then
        UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[4]) + 1] + '分'
      Else
        UpperMoney := UpperMoney + '整';
    End;
  End;
  Result := '';
  For i := 1 To Length(UpperMoney) Do
    If UpperMoney[i] <> ' ' Then
      Result := Result + UpperMoney[i];
End;

Function SmallToBig3(Const rmbSmall: Currency): String;
Var 
  i, j: Integer;
  zheng: Integer;
  ch, Money: String;
  A: Array[1..10] Of String;
  B: Array[1..12] Of String;
  C: Array[1..2] Of String;
Begin
  A[1] := '壹';
  A[2] := '贰';
  A[3] := '叁';
  A[4] := '肆';
  A[5] := '伍';
  A[6] := '陆';
  A[7] := '柒';
  A[8] := '捌';
  A[9] := '玖';
  A[10] := '拾';
  B[1] := '';
  B[2] := '拾';
  B[3] := '佰';
  B[4] := '仟';
  B[5] := '万';
  B[6] := '拾万';
  B[7] := '佰万';
  B[8] := '仟万';
  B[9] := '亿';
  B[10] := '拾亿';
  B[11] := '佰亿';
  B[12] := '仟亿';
  B[12] := '';
  C[1] := '分';
  C[2] := '角';
  //l:=trunc(strtofloat(money));
  Try
    money := floattostr(rmbSmall);
  Except
    ShowError('你转换的数值是一个无效的类型');
    exit;
  End;
  money := formatfloat('0.00', strtofloat(money));
  zheng := length(money) + 1;
  i := length(IntToStr(trunc(strtofloat(money)))) + 1;
  For j := 1 To i - 1 Do
    If (money[j] = '0') And (money[j + 1] = '0') Then
      continue       //判断中间的零
  Else If (money[j] = '0') And ((money[j + 1] <> '0') And (money[j + 1] <> '') And
    (money[j + 1] <> '.')) Then
    ch := ch + A[StrToInt(money[j])] + '零' //得到中间的零
  Else If (i - j = 6) And (money[j + 1] <> '0') Then
    ch := ch + A[StrToInt(money[j])] + '拾'   //拾万数
  Else If (i - j = 7) And (money[j + 1] <> '0') Then
    ch := ch + A[StrToInt(money[j])] + '佰'  //佰万数
  Else If (i - j = 8) And (money[j + 1] <> '0') Then
    ch := ch + a[StrToInt(money[j])] + '仟'   //仟万数
  Else If (i - j = 10) And (money[j + 1] <> '0') Then
    ch := ch + A[StrToInt(money[j])] + '拾'    //拾亿数
  Else If (i - j = 11) And (money[j + 1] <> '0') Then
    ch := ch + A[StrToInt(money[j])] + '佰'    //佰亿数
  Else If (i - j = 12) And (money[j + 1] <> '0') Then
    ch := ch + A[StrToInt(money[j])] + '仟'    //仟亿数
  Else 
  Begin
    ch := ch + A[StrToInt(money[j])] + b[i - j];
  End;
  ch := ch + '元';
  //if (i>2) and (money[i-1]='0') and (money[i+1]<>'0')then
  // ch:=ch+'零';
  j := i;
  If zheng > i Then
    For j := j + 1 To zheng - 1 Do

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -