lesroches Posted October 4, 2004 Posted October 4, 2004 Hi everyone, I have been trying to do the funtion but just could not seem to get it to work, can someone please take a look at it and tell me what is wrong with my entry? If bValidEntries = True Then dMonthlyInvestmet = txtMonthlyInvestment.Text dYearlyInterestRate = txtYearlyInterestRate.Text iNoOfYears = txtNoOfYears.Text iNoOfMonths = iNoOfYears * 12 dMonthlyInterestRate = dYearlyInterestRate / 12 / 100 iKount = 1 lblFutureValue.Text = FormatCurrency(FutureValue _ (dMonthlyInvestmet, dMonthlyInterestRate)) End If AND MY PRIVATE FUNCTION CODE IS Private Function FutureVal( _ ByVal dMI As Decimal, _ ByVal dYIR As Decimal, _ ByVal iNOM As Integer, _ ByVal iCount As Integer, _ ByVal dMIR As Decimal, _ ByVal iNOY As Integer) As Decimal Dim dFutureVal As Decimal iNOM = iNOY * 12 dMIR = dYIR / 12 / 100 For iCount = 1 To iNOM dFutureVal = (dFutureVal + dMI) * (1 + dMIR) Next Return dFutureVal I really do not know where is my error and hopefully you will be able to let me know. Thanks Quote
jayceepoo Posted October 4, 2004 Posted October 4, 2004 First off, I don't really know what the problem is, so this is just a guess. I'm thinking that you are not getting the right answer from your function. I suspect the for loop is your problem. In your for loop, you are reassigning the value of dFutureVal. Are you supposed to add them together? How about this: For iCount = 1 To iNOM dFutureVal += (dFutureVal + dMI) * (1 + dMIR) Next Or if it's just not working at all, it looks like you called the wrong function name... (Here it's called FutureValue) lblFutureValue.Text = FormatCurrency(FutureValue _ (dMonthlyInvestmet, dMonthlyInterestRate)) But your signature says FutureVal Hi everyone, I have been trying to do the funtion but just could not seem to get it to work, can someone please take a look at it and tell me what is wrong with my entry? If bValidEntries = True Then dMonthlyInvestmet = txtMonthlyInvestment.Text dYearlyInterestRate = txtYearlyInterestRate.Text iNoOfYears = txtNoOfYears.Text iNoOfMonths = iNoOfYears * 12 dMonthlyInterestRate = dYearlyInterestRate / 12 / 100 iKount = 1 lblFutureValue.Text = FormatCurrency(FutureValue _ (dMonthlyInvestmet, dMonthlyInterestRate)) End If AND MY PRIVATE FUNCTION CODE IS Private Function FutureVal( _ ByVal dMI As Decimal, _ ByVal dYIR As Decimal, _ ByVal iNOM As Integer, _ ByVal iCount As Integer, _ ByVal dMIR As Decimal, _ ByVal iNOY As Integer) As Decimal Dim dFutureVal As Decimal iNOM = iNOY * 12 dMIR = dYIR / 12 / 100 For iCount = 1 To iNOM dFutureVal = (dFutureVal + dMI) * (1 + dMIR) Next Return dFutureVal I really do not know where is my error and hopefully you will be able to let me know. Thanks Quote
lesroches Posted October 4, 2004 Author Posted October 4, 2004 This is the error message that appear on the screen Argument not specified for parameter 'iNOY' of 'Private Function FutureValue(dMI As Decimal, dYIR As Decimal, iNOM As Integer, iCount As Integer, dMIR As Decimal, iNOY As Integer) As Decimal'. First off, I don't really know what the problem is, so this is just a guess. I'm thinking that you are not getting the right answer from your function. I suspect the for loop is your problem. In your for loop, you are reassigning the value of dFutureVal. Are you supposed to add them together? How about this: For iCount = 1 To iNOM dFutureVal += (dFutureVal + dMI) * (1 + dMIR) Next Or if it's just not working at all, it looks like you called the wrong function name... (Here it's called FutureValue) lblFutureValue.Text = FormatCurrency(FutureValue _ (dMonthlyInvestmet, dMonthlyInterestRate)) But your signature says FutureVal Quote
Simcoder Posted October 4, 2004 Posted October 4, 2004 I'm looking at your code and your only passing 2 values into your function (dmonthlyinvestmet and dmonthlyinterestrate) but when you declared your function, you declared 6 Parameters to it. Quote Whatever thy hand findest to do, do it with all thy heart - Jesus
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.