Update
您的输入框不正确,如果一致输入无效值,则例程将跳至下一行代码!
它们应该如下所示。
Do
inputtedData = InputBox("Please Enter a balance for SAVINGS account between $500.00 and $3000.00", "Initial Savings Balance", "0.00")
If inputtedData = "" Then
MsgBox("User chose to Cancel calculation!")
Exit Sub
Else
initialBalanceSavings = CType(inputtedData, Single)
If initialBalanceSavings > 3000 Or initialBalanceSavings < 500 Then MsgBox("Please enter a balance for SAVINGS account equal to or above $500.00 and no more than $3000.00", MsgBoxStyle.Critical, "Error")
End If
Loop Until initialBalanceSavings >= 500 And initialBalanceSavings <= 3000
Do
inputtedData = InputBox("Please Enter a balance for CORPORATE account between $500.00 and $3000.00", "Initial Corporate Balance", "0.00")
If inputtedData = "" Then
MsgBox("User chose to Cancel calculation!")
Exit Sub
Else
initialBalanceCorporate = CType(inputtedData, Single)
If initialBalanceCorporate > 3000 Or initialBalanceCorporate < 500 Then MsgBox("Please enter a balance for CORPORATE account equal to or above $500.00 and no more than $3000.00", MsgBoxStyle.Critical, "Error")
End If
Loop Until initialBalanceCorporate >= 500 And initialBalanceCorporate <= 3000
最后,所有代码绝对不在“btnMediaEstimatedFund”程序中,因为没有计算总值,也没有考虑到计算是针对未来几年的事实。事实上,关键计算部分丢失了!
我的意思是,如果你想计算出 2016 年的数据,现在是 2013 年,那么你的 7% 和 5% 利息在哪里计算?我看不到它实际计算的任何地方。
您“不知道”如何创建的子例程与您为按钮/文本框/列表框事件创建的子例程没有什么不同!
你传入参数,它就会进行计算,如果它是一个 SUB,那就结束了!如果它是一个函数,那么它返回一个值或一个对象。
要创建子例程,您可以为其指定名称和参数列表,如果需要,您可以拥有不带参数的子例程和函数,但函数必须始终返回值/对象。
Sub ThisIsMySubroutine(MyParam1 as string, My Param2 as Object)
' code here
End Sub
Function ThisIsMyFunction(MyParam1 as string, My Param2 as Object) As Boolean
' code here
End Function
我确信您已经知道参数和返回数据类型可以是任何可接受或认可的数据类型。
更新二
关于您的最后一条评论(从..开始。另外,我有一个小..)如果您交换代码并将原始代码放回去,您仍然会遇到同样的问题!
好的,最后一个代码示例和指针。
因此,要阻止你的程序(10%是你的,90%是我的哈哈哈)请求输入,你可以将其包含在 if 语句中......
If checkBoxSavings.Checked Then
Do
inputtedData = InputBox("Please Enter a balance for SAVINGS account between $500.00 and $3000.00", "Initial Savings Balance", "0.00")
If inputtedData = "" Then
MsgBox("User chose to Cancel calculation!")
Exit Sub
Else
initialBalanceSavings = CType(inputtedData, Single)
If initialBalanceSavings > 3000 Or initialBalanceSavings < 500 Then MsgBox("Please enter a balance for SAVINGS account equal to or above $500.00 and no more than $3000.00", MsgBoxStyle.Critical, "Error")
End If
Loop Until initialBalanceSavings >= 500 And initialBalanceSavings <= 3000
End If
If checkBoxCorporate.Checked Then
Do
inputtedData = InputBox("Please Enter a balance for CORPORATE account between $500.00 and $3000.00", "Initial Corporate Balance", "0.00")
If inputtedData = "" Then
MsgBox("User chose to Cancel calculation!")
Exit Sub
Else
initialBalanceCorporate = CType(inputtedData, Single)
If initialBalanceCorporate > 3000 Or initialBalanceCorporate < 500 Then MsgBox("Please enter a balance for CORPORATE account equal to or above $500.00 and no more than $3000.00", MsgBoxStyle.Critical, "Error")
End If
Loop Until initialBalanceCorporate >= 500 And initialBalanceCorporate <= 3000
End If
对于您的兴趣,这里有一个链接,http://math.about.com/od/businessmath/ss/Interest.htm http://math.about.com/od/businessmath/ss/Interest.htm
这是一个非常好的解释,因为它显示了超过一年的兴趣,这就是你问题的这一部分所要问的......
请注意当前年份 2013 年。现在,报告是在 2013 年准备的,但应根据您选择的年份(例如 2015 年、2016 年、2017 年)计算余额。考虑重复主题以确定所选年份的期末余额