閱讀以下說明和Visual Basic代碼,填入(n)處。 [說明] 在一些財務軟件中,經常需要將阿拉伯數字的賬
閱讀以下說明和Visual Basic代碼,填入(n)處。
[說明]
在一些財務軟件中,經常需要將阿拉伯數字的賬目轉化為漢語習慣中的金額計數方法,例如:
“3.45”轉化為“叁元四角五分”;
“3.4”轉化為“叁元四角”;
“3.40”轉化為“叁元四角零分”;
“3.456”轉化為“叁元四角五分”;
“345.00”轉化為“叁百四十五元零角零分”;
“345”轉化為“叁百四十五元”;
以下Visual Basic代碼實現了小寫金額轉換為大寫金額。界面如圖10-9所示。結合實際例子說明,仔細閱讀下面代碼,將(n)代碼補充完整。
[代碼7-1]
Begin VB.FormForm1
Caption = "小寫金額轉換為大寫金額"
//...窗體描述(略)
Begin VB.CommandButton Command1
Caption = "退出"
//...窗體描述(略)
End
Begin VB.TextBox Text2
//...窗體描述(略)
End
Begin VB.TextBox Text1
Enabled = 0 "False
//…窗體描述(略)
End
Begin VB.Labe1 Labe12
Caption = "轉換為大寫金額"
//...窗體描述(略)
End
Begin VB.Labe1 Labe11
Caphon = "請輸入數字"
//...窗體描述(略)
End
End
[代碼7-2]
Private Function setdata (num As Integer) As String "數字轉換
Select CaSe num
Case 0
setdata="零"
Case 1
Setdata="壹"
Case 2
Setdata="貳"
Case 3
Setdata="叁"
Case4
Setdata="肆"
Case 5
Setdata="伍"
Case 6
Setdata="陸"
Case 7
Setdata="柒"
Case 8
Setdata="捌"
Case 9
Setdata="玖"
End Select
End Function
Private Function chang (aaa As Integer) As String "位數轉換
Select CaSe aaa
Case 1
chang=""
Case 2
chang="十"
Case 3
chang="百"
Case 4
chang="千"
Case 5
chang="萬"
Case 6
chang="十"
Case 7
chang="百"
Case 8
chang="千"
Case 9
chang="億"
Case 10
chang="十"
End Select
End Function
[代碼7-3]
Private Sub Text2_Change ( ) "小寫轉大寫
Dim i As Integer
Dim j As Integer
Dim myint As Integer
Dim myint1 As Integer
Dim mydoub As Double
Dim mystr As String
Dim mystr1 As String
Dim mystr2 As String
Dim mystr3 As String
Dim mystr4 As String
Dim money As Long
Dim money1 As Integer
Dim money2 As Long
mystr=Text2.Text
myint=InStr (mystr, ".")
If myint=0 Then
mystr=Text2.Text
Else
mystr3=Right(Text2.Text, Len (Text2.Text ) - myint)
If mystr3<>""Then "轉換小數位
mystr4=Left(mystr3, 1)
mystr3=Right(mystr3, Len(mystr3 )
正確答案:(1)mystr2=mystr2+setdata(Val(mystr4))+"角"(2)mystr2=mystr2+setdata(Val(mystr4))+"分"(3)If Right(mystr11) >"萬"Then mystr1=mystr1&"萬"(4)I fRight(mystr11) >"零"And Right(moneyj) >0 Then mystr1=mystr1&"零"(5)mystr1=mystr1 & setdata(money1)
詞條內容僅供參考,如果您需要解決具體問題
(尤其在法律、醫學等領域),建議您咨詢相關領域專業人士。