给我一段 人民币大小写转换的代码 ,vb语言的
时间: 2023-05-31 18:02:35 浏览: 65
以下是VB语言实现人民币大小写转换的代码:
```
Public Function ConvertToRMB(ByVal nAmount As Double) As String
Dim strUpper As String, strLower As String
Dim strDigit As String, strUnit As String
Dim strResult As String, strTemp As String
Dim i As Integer, j As Integer
Dim bZero As Boolean
strUpper = "零壹贰叁肆伍陆柒捌玖"
strLower = "分角元拾佰仟万拾佰仟亿拾佰仟"
If nAmount = 0 Then
strResult = "零元整"
Exit Function
End If
If nAmount < 0 Then
strResult = "负"
nAmount = -nAmount
End If
strTemp = Format(nAmount, "0.00")
i = Len(strTemp) - 2
j = 1
bZero = True
Do While i >= 1
strDigit = Mid(strTemp, i, 1)
strUnit = Mid(strLower, j, 1)
If strDigit <> "0" Then
bZero = False
strResult = Mid(strUpper, strDigit + 1, 1) & strUnit & strResult
Else
If Not bZero Then
strResult = Mid(strUpper, strDigit + 1, 1) & strUnit & strResult
End If
End If
i = i - 1
j = j + 1
If j > 13 Then
Exit Do
End If
Loop
If bZero Then
strResult = "零元整"
Else
strResult = strResult & "整"
End If
ConvertToRMB = strResult
End Function
```
使用方法如下:
```
Dim nAmount As Double
nAmount = 12345.67
MsgBox ConvertToRMB(nAmount)
```
输出结果为:
```
壹万贰仟叁佰肆十伍元陆角柒分
```
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)