在开发过程中,选择币种和存期的组合框(ComboBox)名分别为Combo1和Combo2,单旋钮 (CommandButton)“个人单位”和“金融机构”分别名为Option1和Option2,用于输入本金的文本框 (TextBox)名为Price,“输出日利率”和“计算本利和”按钮(CommandButton)分别名为Command1和 Command2。且已知,第i类币种、第j类存期之下,个人单位与金融机构的存款日利率分别存放于数组元素interestRate(i,j,0)和interestRate(i,j,1)中,其中i,j从0开始计数。
Private Sub Form_Load()
…… ’为数组interestRate赋初值
E.nd Sub
’根据所选择的币种、存期等信息确定日利率
F.unction getInterestRate()
D.im strCurrency, strTime As String, i, j, k, intDays As Integer
strCurrency = Combo1.Text
strTime = Combo2.Text
F.or i = 0 To Combol. ListCount - 1
If Combol.List(i) = strCurrency Then (1)
Next
F.or j = 0 To Combo2.ListCount - 1
IfCombo2.List(j) = strTime Then (1)
Next
If (2)=True Then
k=0
E.lse: k=1
E.nd If(3)= interestRate(i, j, k)
E.nd Function
’输出日利率
Private Sub Commund1_Click()
MsgBox "日利率为" & getInterestRate()
E.nd Sub
’输出本利和
Private Sub Command2_Click()
D.im strTime As String, intDays As Integer, sngCorpus, sngResult As Single
strTime = Combo2. Text
sngCorpus = CSng(Text1.Text)(4) ’计算存款天数(以每月30天计)
C.ase "一个月" :intDays = 30
C.ase "三个月" :intDays = 90
C.ase "六个月" :intDays = 120
E.nd Select
’计算并输出本利和
sngResult = sngCorpus +(5)
MsgBox "本利之和为:" & sngResult
E.nd Sub