Dim Ans Private Sub Form_Load() '零 壹 貳 參 肆 伍 陸 柒 捌 玖 拾 佰 仟 萬 億 Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, n Ans = "" Dim s
s = Split(" 拾 佰 仟 萬 億") For i = 1 To Len(n) m = Mid(n, i, 1) Call CHs(m) If m <> 0 Then If (Len(n) + 1 - i) <= 5 Then Ans = Ans & s((Len(n) - i)) If (Len(n) + 1 - i) > 5 Then Ans = Ans & s((Len(n) + 1 - i) - 5) & s(4) If (Len(n) + 1 - i) > 9 Then Ans = Ans & s((Len(n) + 1 - i) - 9) & s(5) End If Next Do While Right(Ans, 1) = "零" Ans = Left(Ans, Len(Ans) - 1) Loop Print #2, Ans Loop Close Close End End Sub
Sub CHs(a) Dim Q Q = Split("零 壹 貳 參 肆 伍 陸 柒 捌 玖") Ans = Ans & Q(a) End Sub
Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 X = Split(" ,拾,佰,仟,萬,拾,佰,仟,億,拾,佰,仟,兆", ",") Do While Not EOF(1) Input #1, N ans = "" K = 0 For i = Len(N) To 1 Step -1 ans = Mid(N, i, 1) & X(K) & ans K = K + 1 Next i
ans = Replace(ans, "1", "壹") ans = Replace(ans, "2", "貳") ans = Replace(ans, "3", "參") ans = Replace(ans, "4", "肆") ans = Replace(ans, "5", "伍") ans = Replace(ans, "6", "陸") ans = Replace(ans, "7", "柒") ans = Replace(ans, "8", "捌") ans = Replace(ans, "9", "玖") ans = Replace(ans, "0", "零") ans = Replace(ans, "零拾", "零") ans = Replace(ans, "零佰", "零") ans = Replace(ans, "零仟", "零") ans = Replace(ans, "零萬", "零") Do ans = Replace(ans, "零零", "零") Loop Until InStr(ans, "零零") = 0 ans = Replace(ans, " ", "")
If Mid(ans, Len(ans), 1) = "零" Then ans = Mid(ans, 1, Len(ans) - 1) Print #2, ans Loop Close #2 Close #1
Dim Ans
回覆刪除Private Sub Form_Load()
'零 壹 貳 參 肆 伍 陸 柒 捌 玖 拾 佰 仟 萬 億
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, n
Ans = ""
Dim s
s = Split(" 拾 佰 仟 萬 億")
For i = 1 To Len(n)
m = Mid(n, i, 1)
Call CHs(m)
If m <> 0 Then
If (Len(n) + 1 - i) <= 5 Then Ans = Ans & s((Len(n) - i))
If (Len(n) + 1 - i) > 5 Then Ans = Ans & s((Len(n) + 1 - i) - 5) & s(4)
If (Len(n) + 1 - i) > 9 Then Ans = Ans & s((Len(n) + 1 - i) - 9) & s(5)
End If
Next
Do While Right(Ans, 1) = "零"
Ans = Left(Ans, Len(Ans) - 1)
Loop
Print #2, Ans
Loop
Close
Close
End
End Sub
Sub CHs(a)
Dim Q
Q = Split("零 壹 貳 參 肆 伍 陸 柒 捌 玖")
Ans = Ans & Q(a)
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
X = Split(" ,拾,佰,仟,萬,拾,佰,仟,億,拾,佰,仟,兆", ",")
Do While Not EOF(1)
Input #1, N
ans = ""
K = 0
For i = Len(N) To 1 Step -1
ans = Mid(N, i, 1) & X(K) & ans
K = K + 1
Next i
ans = Replace(ans, "1", "壹")
ans = Replace(ans, "2", "貳")
ans = Replace(ans, "3", "參")
ans = Replace(ans, "4", "肆")
ans = Replace(ans, "5", "伍")
ans = Replace(ans, "6", "陸")
ans = Replace(ans, "7", "柒")
ans = Replace(ans, "8", "捌")
ans = Replace(ans, "9", "玖")
ans = Replace(ans, "0", "零")
ans = Replace(ans, "零拾", "零")
ans = Replace(ans, "零佰", "零")
ans = Replace(ans, "零仟", "零")
ans = Replace(ans, "零萬", "零")
Do
ans = Replace(ans, "零零", "零")
Loop Until InStr(ans, "零零") = 0
ans = Replace(ans, " ", "")
If Mid(ans, Len(ans), 1) = "零" Then ans = Mid(ans, 1, Len(ans) - 1)
Print #2, ans
Loop
Close #2
Close #1
End
End Sub