'将数值转换为金额的简体或繁体大写形式，返回转换后的文本。
Function NumToRMB(nNum As Double, jf As Long = False) As String '将数值转换为金额的简体或繁体大写形式，返回转换后的文本。{2.False  繁体.True  简体}
   Dim NumStr As String = Format(nNum, "0.00")
   Dim dStr As String = "垓仟佰拾京仟佰拾兆仟佰拾亿仟佰拾万仟佰拾圆角分"
   Dim mStr As String = "零壹贰叁肆伍陆柒捌玖"
   If jf <> 0 Then
      dStr = "垓千百十京千百十兆千百十亿千百十万千百十元角分"
      mStr = "零一二三四五六七八九"
   End If
   Dim outStr As String = Space(Len(NumStr) * 4)
   Dim As Long i ,bu,nu ,ou
   bu = Len(dStr) -1
   nu = Len(NumStr) -1
   ou = Len(outStr) -3
   For i = 1 To Len(NumStr)
      Select Case NumStr[nu]
         Case 46  '小数点 不处理
            nu -= 1
         Case 48 '0 处理
            If ou < Len(outStr) -3 Then '
               Select Case Mid(outStr, ou + 4, 2)
                  Case "零", "元", "圆", "万", "亿", "兆", "京", "垓"
                     
                  Case Else
                     Mid(outStr, ou + 2, 2) = "零"
                     ou -= 2
               End Select
            End If
            Select Case Mid(dStr, bu, 2)
               Case "元", "圆", "万", "亿", "兆", "京", "垓"
                  Select Case Mid(outStr, ou + 4, 2)
                     Case "万", "亿", "兆", "京", "垓"
                        Mid(outStr, ou + 4, 2) = Mid(dStr, bu, 2)
                     Case Else
                        Mid(outStr, ou + 2, 2) = Mid(dStr, bu, 2)
                        ou -= 2
                  End Select
               Case Else
            End Select
            bu -= 2
            nu -= 1
         Case Else
            Select Case Mid(dStr, bu, 2)
               Case "亿", "兆", "京", "垓"
                  Select Case Mid(outStr, ou + 4, 2)
                     Case "万", "亿", "兆", "京"
                        ou += 2
                  End Select
               Case Else
            End Select
            Mid(outStr, ou + 2, 2) = Mid(dStr, bu, 2)
            Mid(outStr, ou, 2) = Mid(mStr, (NumStr[nu] -48) * 2 + 1, 2)
            bu -= 2
            ou -= 4
            nu -= 1
      End Select
   Next
   outStr = Trim(outStr)
   If outStr = "元" Then
      outStr = "零元"
   ElseIf outStr = "圆" Then
      outStr = "零圆"
   ElseIf Left(outStr, 4) = "圆零" Or Left(outStr, 4) = "元零" Then
      outStr = Mid(outStr, 5)
   End If
   If Right(outStr, 2) <> "分" Then outStr &= "整"
   Function = outStr
End Function