請問在ACCESS下在報表檢視下如何將數字轉換成大寫金額例:58770轉換印出為伍萬捌仟柒佰柒拾元整,請幫幫忙謝謝
2006-09-19 08:17:29 · 2 個解答 · 發問者 恩 1 in 電腦與網際網路 ➔ 程式設計
我只是初學者,在報表設計中要如何把輸出資料轉換成大寫金額呢?
2006-09-19 14:46:37 · update #1
可以用圖來解說嗎?
2006-09-19 21:02:23 · update #2
Enum nDec 元 = 0 角 = 1 分 = 2 錢 = 3 厘 = 4End EnumPrivate Sub Command0_Click() MsgBox N2C("1234567890123456.1299", 分)End Sub'N=要轉之數字,M=小數點位數0~4,預設值為0,整數部份最高到16位(仟兆)Function N2C$(ByVal N$, Optional M As nDec = 0) Dim A, B, I%, J%, S$, F$, K$ If IsNumeric(N) = False Then Exit Function If InStr(N, "-") Then N = Replace(N, "-", ""): F = "-" If M Then K = "." & String(M, "0") N = CDec(Format(N, "0" & K)) J = InStr(N, ".") If J Then K = Mid(N, J + 1): N = CDec(Int(N)) If Len(N) > 16 Then N2C = "溢位": Exit Function A = Array("", "壹", "貳", "參", "四", "伍", "陸", "柒", "捌", "玖") B = Array("", "拾", "佰", "仟", "萬", "拾萬", "佰萬", "仟萬", "億", "拾億", _ "佰億", "仟億", "兆", "拾兆", "佰兆", "仟兆") For I = Len(N) To 1 Step -1 J = Mid$(N, I, 1) If J Then S = A(J) & B(Len(N) - I) & S Else If Left(S, 1) <> "零" Then S = "零" & S End If Next If Len(S) > 1 Then If Right(S, 1) = "零" Then S = Left(S, Len(S) - 1) End If If Left(S, 2) = "一拾" Then S = Mid(S, 2) For I = 4 To 12 Step 4 Do Until InStr(S, B(I)) = InStrRev(S, B(I)) S = Replace(S, B(I), "", , 1) Loop Next S = F & S & "元" If K <> "" Then B = Array("角", "分", "錢", "厘") For I = 1 To Len(K) If Mid(K, I, 1) = 0 Then If Right(S, 1) <> "零" Then S = S & "零" Else S = S & A(Mid(K, I, 1)) & B(I - 1) End If Next N2C = S Else N2C = S & "整" End IfEnd Function
2006-09-19 17:39:24 補充:
請將
If Left(S, 2) = "一拾" Then S = Mid(S, 2)
改成
If Left(S, 2) = "壹拾" Then S = Mid(S, 2)
A = Array(.. "四"..
改成
A = Array(.. "肆"..
2006-09-20 05:30:52 補充:
已無法用圖片來解說,只好請你自己下載來看吧(版本:Access2000,免費空間只能放7天)
http://www.yousendit.com/transfer.php?action=check_download&ufid=60D982352772D629&key=a58f8b1050e67613e6750417ff3281324203ac06
2006-09-19 13:09:30 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
可以參考這個連結,希望對你有幫助
http://excelvba.g-tw.com/plog/post/1/109
2006-09-19 09:23:27 · answer #2 · answered by BEN 1 · 0⤊ 0⤋