CodeI: ' Rdlc User-Defined Function numbers are converted to RMB in upper case (amount). Currently, only Yuan is supported, solving the problem of zero angle.
Function cnmoney (byval money as string, optional byval Yb as Boolean = true) as string
Dim X, Y as string
Dim I as integer
Const zimu = " . Sbqwsbqysbqwsbq " '' Location definition code
Const letter = " 0123456789sbqwy. zjf " '' Define Chinese characters abbreviations
Const upcase = " 0, 1, 3, 3, 3, 3, 3, 3 " ' Define uppercase Chinese Characters
Dim temp as string
Try
Temp = convert. tostring (format (convert. todouble (money ), " 0.00 " ))
Catch ex as exception
Throw new notsupportedexception ( " Data error (non-digit format )! " )
Cnmoney = " Error. "
Exit Function
End try
If Len (temp)> 12 Then
Throw new notsupportedexception ( " The data is too big to be computed (over bits cannot be computed )! " )
Cnmoney = " Error. "
Exit Function
End if
If instr (temp, " . " )> 0 Then temp = left (temp, instr (temp, " . " )- 1 )
X = format (convert. todouble (money ), " 0.00 " ) ' Format currency
Y = ""
For I = 1 To Len (x )- 3
Y = Y & Mid (X, I, 1 ) & Mid (zimu, Len (x )- 2 -I, 1 )
Next
If right (X, 3 ) = " . 00 " Then
Y = Y & " Z " '' * ** RMB
Else
If right (X, 1 ) = " 0 " Then
Y = Y & left (right (X, 2 ), 1 )& " J " & " Z " ' * Yuan * angle * integer
Else
Y = Y & left (right (X, 2 ), 1 )& " J " & Right (X, 1 )& " F " '' * Yuan * angle * points
End if
End if
Y = Replace (Y, " 0q " , " 0 " ) '' Avoid 40200 (for example, million RMB and million RMB)
Y = Replace (Y, " 0b " , " 0 " ) '' Avoid Zero traffic (for example, 41000 million RMB)
Y = Replace (Y, " 0 s " , " 0 " ) '' Avoid zero or ten (for example, 204 million records and zero inventory)
Do While Y <> Replace (Y, " 00 " , " 0 " )
Y = Replace (Y, " 00 " , " 0 " ) '' Avoid dual zeros (for example, 1004)
Loop
Y = Replace (Y, " 0y " , " Y " ) '' Avoid Zero loss (for example, 210 million RMB, million RMB)
If Val (mid (right (temp, 4 ), 1 , 1 )> 0 Then
Y = Replace (Y, " 0 w " , " W0 " ) '' Avoid Zero loss (for example: 102000 It should be
Else
Y = Replace (Y, " 0 w " , " W " ) '' Avoid Zero loss (for example, 210 million RMB, million RMB)
End if
' Y = IIF (LEN (x) = 5 and left (Y, 1) = "1", right (Y, Len (y)-1), Y) '' Avoid ten items (for example, 14 items and 10 items)
Y = IIF (LEN (x) = 4 , Replace (Y, " 0. " , "" ), Replace (Y, " 0. " , " . " )) '' Avoid zero RMB (e.g: 20 . 00 then pick up the circle; 0 . 12)
If Len (temp)> = 9 Then ' Add
Y = Replace (Y, " YW " , " Y " ) ' To avoid billions of yuan, for example, 100000000 yuan, one billion yuan should be one billion yuan
End if ' Add
For I = 1 To 19
Y = Replace (Y, mid (letter, I, 1 ), Mid (upcase, I, 1 )) '' Uppercase Chinese Characters
Next
Y = Y. Replace ( " Zero Angle " , " Zero " )
If Yb = false then
Y = Y. Replace ( " Round " , "" )
End if
Cnmoney = y
End Function
Call = code. cnmoney ( 102.3534 )
Test results:
1409.50 Yanyinqianxiao
6007.14 Lu Yu, Yi Yuan, Yi Jiao Si
1680.32
107000 . 53 minutes
16409 . 02 ten thousand Lu xiaosi Yu 0 Yuan 0 Points
325.04 Wu Yuan, Wu Yuan, Min
900100001 . Yuan and Yuan
This article was found on the internet and changed a little bit. If you have any questions, leave a message.
If you have a better solution, please describe it. Thank you.
The following code is a bit problematic and will be modified later:
Code 2:
Function cnmoney (Num as string) as string
If isnumeric (Num) = false or num =""Then
Cnmoney = num
Exit Function
End if
Dim S1, S2, sin, resultstr, namount as string
S1 ="Zero-risk migration"
S2 ="Hundreds of millions of users, hundreds of millions of users, hundreds of millions of users, and tens of thousands of users"
Namount = trim (STR (Val (Num )*100))
Dim numlength as integer
Numlength = Len (TRIM (STR (namount )))
Dim usestr as string
Usestr = mid (S2, (LEN (S2)-numlength +1), Numlength)
Dim zerocounter, flag as integer
Zerocounter =0
Flag =0
Do while flag <Len (namount)
Flag = Flag +1
Dim cnnum as string
Cnnum = mid (namount, flag,1)
Cnnum = mid (S1, Val (cnnum) +1,1)
Sin = mid (usestr, flag,1)
If cnnum ="Zero"Then
Cnnum =""
If sin ="Billion"Or Sin ="RMB"Then
Elseif sin ="10 thousand"Then
If mid (resultstr, Len (resultstr ),1) ="Billion"Then
Sin =""
End if
Else
Sin =""
End if
Zerocounter = zerocounter +1
Else
If zerocounter>0Then
Cnnum ="Zero"+ Trim (cnnum)
Zerocounter =0
End if
End if
Resultstr = trim (resultstr) + trim (cnnum) + trim (SIN)
Loop
If mid (namount, Len (namount ),1) ="0"Then
Cnmoney = resultstr +"Integer"
Else
Cnmoney = resultstr
End if
End Function
The problem is as follows:
107000. 53 pick up tens of thousands of workers
The following two statements are correct:
I have collected tens of thousands of yuan worth of points
I have collected tens of thousands of yuan and scored three points