Board logo

标题: [转贴] 人民币大小写转换.vbs [打印本页]

作者: fastslz    时间: 2011-7-19 10:09     标题: 人民币大小写转换.vbs

  1. mCn=Inputbox ("请输入小写数字:","提示信息...","0.00")
  2. If IsNumeric(mCn) And mCn<>"" then
  3.   Cn=MoneyCn(Abs(Trim(mCn)))
  4.   MsgBox Abs(Trim(mCn))&Chr(10)&Cn, 64, "转换结果..."
  5. Else
  6.   MsgBox "不是合理的人民币数字!", 64, "错误信息..."
  7. End If
  8. Function MoneyCn(Num)
  9.   if Instr(1,""&Num,".")=0 then
  10.     Num=Num&".00"
  11.   end if
  12.   pp=Instr(1,""&Num,".")-1
  13.   ll=len(Num)
  14.   For i=1 to ll
  15.     ss=Mid(Num,i,1)
  16.     Select case ss
  17.       case "."
  18. Result=Result&"元"
  19.       case "0"
  20. Result=Result&"零"
  21.       case "1"
  22. Result=Result&"壹"
  23.       case "2"
  24. Result=Result&"贰"
  25.       case "3"
  26. Result=Result&"叁"
  27.       case "4"
  28. Result=Result&"肆"
  29.       case "5"
  30. Result=Result&"伍"
  31.       case "6"
  32. Result=Result&"陆"
  33.       case "7"
  34. Result=Result&"柒"
  35.       case "8"
  36. Result=Result&"捌"
  37.       case "9"
  38. Result=Result&"玖"
  39.     End Select
  40.     mm=pp-i
  41.     Select case mm
  42.       case -5
  43. Result=Result&"毫"
  44.       case -4
  45. Result=Result&"厘"
  46.       case -3
  47. Result=Result&"分"
  48.       case -2
  49. Result=Result&"角"
  50.       case 1
  51. Result=Result&"拾"
  52.       case 2
  53. Result=Result&"佰"
  54.       case 3
  55. Result=Result&"仟"
  56.       case 4
  57. Result=Result&"万"
  58.       case 5
  59. Result=Result&"拾"
  60.       case 6
  61. Result=Result&"佰"
  62.       case 7
  63. Result=Result&"仟"
  64.       case 8
  65. Result=Result&"亿"
  66.       case 9
  67. Result=Result&"拾"
  68.       case 10
  69. Result=Result&"佰"
  70.       case 11
  71. Result=Result&"仟"      
  72.     End Select
  73.   Next
  74.   Result=Replace(Result, "零仟", "零")
  75.   Result=Replace(Result, "零佰", "零")
  76.   Result=Replace(Result, "零拾", "零")
  77.   Result=Replace(Result, "零零", "零")
  78.   Result=Replace(Result, "零零", "零")
  79.   Result=Replace(Result, "零零", "零")
  80.   Result=Replace(Result, "零元", "元")
  81.   Result=Replace(Result, "零角零分", "整")
  82.   MoneyCn=Result
  83. End Function
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2