閱讀以下說明和Visual Basic代碼,填入(n)處。 [說明] 在一些財(cái)務(wù)軟件中,經(jīng)常需要將阿拉伯?dāng)?shù)字的賬
閱讀以下說明和Visual Basic代碼,填入(n)處。
[說明]
在一些財(cái)務(wù)軟件中,經(jīng)常需要將阿拉伯?dāng)?shù)字的賬目轉(zhuǎn)化為漢語習(xí)慣中的金額計(jì)數(shù)方法,例如:
“3.45”轉(zhuǎn)化為“叁元四角五分”;
“3.4”轉(zhuǎn)化為“叁元四角”;
“3.40”轉(zhuǎn)化為“叁元四角零分”;
“3.456”轉(zhuǎn)化為“叁元四角五分”;
“345.00”轉(zhuǎn)化為“叁百四十五元零角零分”;
“345”轉(zhuǎn)化為“叁百四十五元”;
以下Visual Basic代碼實(shí)現(xiàn)了小寫金額轉(zhuǎn)換為大寫金額。界面如圖10-9所示。結(jié)合實(shí)際例子說明,仔細(xì)閱讀下面代碼,將(n)代碼補(bǔ)充完整。
[代碼7-1]
Begin VB.FormForm1
Caption = "小寫金額轉(zhuǎn)換為大寫金額"
//...窗體描述(略)
Begin VB.CommandButton Command1
Caption = "退出"
//...窗體描述(略)
End
Begin VB.TextBox Text2
//...窗體描述(略)
End
Begin VB.TextBox Text1
Enabled = 0 "False
//…窗體描述(略)
End
Begin VB.Labe1 Labe12
Caption = "轉(zhuǎn)換為大寫金額"
//...窗體描述(略)
End
Begin VB.Labe1 Labe11
Caphon = "請(qǐng)輸入數(shù)字"
//...窗體描述(略)
End
End
[代碼7-2]
Private Function setdata (num As Integer) As String "數(shù)字轉(zhuǎn)換
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 "位數(shù)轉(zhuǎn)換
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 ( ) "小寫轉(zhuǎn)大寫
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 "轉(zhuǎn)換小數(shù)位
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)
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。