ÈËÃñ±Ò´óд
Private Function Num2Char(ByVal I As Integer) As String ½«Ð¡Ð´Êý×ÖתΪ´óдÊý×Ö If I >= 0 And I <= 9 Then Num2Char = Mid$("ÁãÒ¼·¡ÈþËÁÎé½Æâ°Æ¾Á", I + 1, 1) Else Num2Char = "" End If End FunctionPrivate Function Num2RMB(ByVal sFourBitString As String, Optional _ ByVal sUnit As String = "Ôª", Optional ByVal bMustHeader As _ Boolean = False) As String ½×¶Î±ä»»(¸öλÖÁǧλ,ÍòλÖÁǧÍòλ,ÒÚλÖÁǧÒÚλ)ÖеĴóд´¦Àí »á³öÏÖµÄÎÊÌâ:¸öλ,Íòλ,ÒÚλΪ0ʱ´óд²»¼ÓÁã,½×¶ÎÖÐȫΪ0ʱ²»¼ÓÁã.ÎÊÌâÔÚºóÃæÐÞÕý. Dim vNum, I, RX, BR, hdr, bNum BR = "Ǫ°ÛÊ°Ôª" vNum = Trim(Str(Val(sFourBitString))) ·µ»ØÓÐЧ×Ö·û´®,×î¶àËÄλ bNum = vNum If (Len(vNum) < 4 And Len(vNum) > 0) And bMustHeader Then hdr = "Áã" Else hdr = "" RX = "" Do While Len(vNum) > 0 I = Right(vNum, 1) If I > 0 Then RX = Num2Char(I) + Right(BR, 1) + RX Else If Left(RX, 1) <> "Áã" Then RX = "Áã" + RX End If vNum = Left(vNum, Len(vNum) - 1) BR = Left(BR, Len(BR) - 1) Loop RX = Left(RX, Len(RX) - 1) If Right(RX, 1) = "Áã" Then È¥³ý¶àÓàµÄÁã RX = Left(RX, Len(RX) - 1) End If If Len(RX) > 0 Then Num2RMB = hdr + RX + sUnit Else Num2RMB = RX + IIf(sUnit = "Ôª", "Ôª", "") End If ¡ï ÐÞÕý¸öλ,Íòλ,ÒÚλΪ0ʱ´óд²»¼ÓÁãµÄÎÊÌâ.Èç:"20.5"»áд×÷"·¡Ê°Ôª(Áã)Îé½ÇÕû","208000"»áд×÷"·¡Ê°Íò(Áã)°ÆǪԪÕû". »á³öÏÖµÄÎÊÌâ:´óдÖлá³öÏÖÖظ´Áã,½áβ"Õû"»ò"ÔªÕû"Ç°»á³öÏÖ¶àÓàµÄÁã.ÎÊÌâ»áÔÚ´úÂë½áβ´¦ÐÞÕý. If Len(bNum) > 1 And Right(bNum, 1) = 0 Then Num2RMB = Num2RMB + "Áã" End If ¡ï End Function Function GetDXJE(ByVal Num As Currency) As String µÃµ½´óд½ð¶î Dim vNum, vDec, ret, qb, js, s vNum = Right(Format$(Int(Num), "000000000000"), 12) È¡Ê®¶þλÕûÊý vDec = Right(Format$(Int(Num * 100 + 0.5), "00"), 2) ȡСÊýµãºóÁ½Î»²¢×Ô¶¯ËÄÉáÎåÈë ret = Num2RMB(Left(vNum, 4), "ÒÚ", False) If Len(ret) = 0 Then ret = Num2RMB(Mid(vNum, 5, 4), "Íò", False) Else ret = ret + Num2RMB(Mid(vNum, 5, 4), "Íò", True) ¡ï ÐÞÕýÍòλÖÁǧÍòλ½×¶ÎÖÐȫΪ0ʱ²»¼ÓÁãµÄÎÊÌâ,Èç:"800008000"»áд×÷"°ÆÒÚ(Áã)°ÆǪԪÕû". »á³öÏÖ¶àÓàÁãµÄÎÊÌâ,Èç:"800000000"»áд×÷"°ÆÒÚÁãÔªÕû". If Mid(vNum, 5, 1) = 0 And Mid(vNum, 6, 1) = 0 And Mid(vNum, 7, 1) = 0 And Mid(vNum, 8, 1) = 0 Then ret = ret + "Áã" End If ¡ï End If If Len(ret) = 0 Then ret = Num2RMB(Right(vNum, 4), "Ôª", False) Else ret = ret + Num2RMB(Right(vNum, 4), "Ôª", True) ¡ï ÐÞÕý¸öλÖÁǧλ½×¶ÎÖÐȫΪ0ʱ²»¼ÓÁãµÄÎÊÌâ,Èç:"80000.1"»áд×÷"°ÆÍòÔª(Áã)Ò¼½ÇÕû". »á³öÏÖ¶àÓàÁãµÄÎÊÌâ. If Mid(vNum, 9, 1) = 0 And Mid(vNum, 10, 1) = 0 And Mid(vNum, 11, 1) = 0 And Mid(vNum, 12, 1) = 0 Then ret = ret + "Áã" End If ¡ï End If If ret = "Ôª" Then ret = "" qb = "" Else qb = "xx" End If If vDec = "00" And qb <> "" Then 1.00 ret = ret + "Õû" End If If vDec = "00" And qb = "" Then 0.00 ret = "Áã" End If If Left(vDec, 1) <> "0" And Right(vDec, 1) = 0 And qb <> "" Then 1.20 ret = ret + Num2Char(Left(vDec, 1)) + "½ÇÕû" End If If Left(vDec, 1) = "0" And Right(vDec, 1) <> 0 And qb <> "" Then 1.03 ret = ret + "Áã" + Num2Char(Right(vDec, 1)) + "·Ö" End If If Left(vDec, 1) <> "0" And Right(vDec, 1) <> 0 And qb <> "" Then 1.23 ret = ret + Num2Char(Left(vDec, 1)) + "½Ç" + Num2Char(Right(vDec, 1)) + "·Ö" End If If Left(vDec, 1) <> "0" And Right(vDec, 1) = 0 And qb = "" Then 0.20 ret = Num2Char(Left(vDec, 1)) + "½ÇÕû" End If If Left(vDec, 1) = "0" And Right(vDec, 1) <> 0 And qb = "" Then 0.03 ret = Num2Char(Right(vDec, 1)) + "·Ö" End If If Left(vDec, 1) <> "0" And Right(vDec, 1) <> 0 And qb = "" Then 0.23 ret = Num2Char(Left(vDec, 1)) + "½Ç" + Num2Char(Right(vDec, 1)) + "·Ö" End If ¡ïÐÞÕý´óдÖгöÏÖÖظ´ÁãµÄÎÊÌâ.Èç:"800800"»áд×÷"°ÆÊ°ÍòÁãÁã°Æ°ÛÔªÕû". ÐÞÕý´óд"Ôª"Ç°³öÏÖ¶àÓàÁãµÄÎÊÌâ.Èç:"800000.1"»áд×÷"°ÆÊ°ÍòÁãÔªÕûÁãÒ¼½ÇÕû". ÐÞÕý´óд½áβ"Õû"Ç°³öÏÖ¶àÓàÁãµÄÎÊÌâ.Èç:"200"»áд×÷"·¡°ÛÔªÁãÕû". js = 0 Do While js <> Len(ret) js = Len(ret) For s = 2 To Len(ret) - 1 If Mid(ret, s, 1) = "Áã" Then If Mid(ret, s + 1, 1) = "Áã" Or Mid(ret, s + 1, 1) = "Ôª" Or Mid(ret, s + 1, 1) = "Õû" Then ret = Left(ret, s - 1) + Right(ret, Len(ret) - s) Exit For End If End If Next Loop ¡ï GetDXJE = ret End Function
--------------------------------------------------------------------------------
Ïà¹ØÎÄÕÂ
ûÓÐÏà¹ØÎÄÕÂ
|