Link to home
Start Free TrialLog in
Avatar of Eliana1
Eliana1

asked on

I am not good at VB and need help with this code

I don't remeber how to invoke a method to a new object.  Here is the code my issues start at line 33
Private Sub findMortgagePayment()
        Dim prompt As String
        Dim validPV As Boolean = False
        Dim validAPR As Boolean = False
        Dim validTerm As Boolean = False
        Dim principal As Double
        Dim apr As Double
        Dim term As Integer

        Try
            '***********************************************************************
            'implement input validation and set local variables  here
            '***********************************************************************
            If validatePrincipalAmount() Then
                principal = Double.Parse(txtMortgageAmount.Text)
                validPV = True
            Else
                txtMortgageAmount.Clear()
            End If
            If validateInterestRate() Then
                apr = Double.Parse(txtInterestRate.Text)
                validAPR = True
            Else
                txtInterestRate.Clear()
            End If
            If validateTerm() Then
                term = Integer.Parse(txtMortgageTerm.Text)
                validTerm = True
            Else
                txtMortgageTerm.Clear()
            End If
           
            If validPV AndAlso validAPR AndAlso validTerm Then
                '***********************************************************************
                ' declare and create a new mortgage data object  
                ' invoke this class's displayPayment method
                ' invoke this class's displayAmoritizationTable method
                '***********************************************************************
                Dim mortgageData As MortgageData
                mortgageData = New MortgageData()



            Else
                lblAmount.Text = ""
                ToolTip1.SetToolTip(lblAmount, "")
                ToolTip1.SetToolTip(rtfAmortTable, "")
                If Not validPV Then
                    prompt = "Please re-enter the loan amount information and try again"
                    InputUtilities.ShowErrorMessage(prompt, "Invalid Loan value")
                    txtMortgageAmount.Focus()
                ElseIf Not validAPR Then
                    prompt = "Please re-enter the interest rate information and try again"
                    InputUtilities.ShowErrorMessage(prompt, "Invalid Interest rate value")
                    txtInterestRate.Focus()
                Else
                    prompt = "Please re-enter the term length information and try again"
                    InputUtilities.ShowErrorMessage(prompt, "Invalid Term value")
                    txtMortgageTerm.Focus()
                End If
            End If
        Catch ex As Exception
            prompt = "Please re-enter the loan information and try again"
            InputUtilities.ShowErrorMessage(ex, prompt)
            ClearFields()
        End Try
    End Sub

    Private Sub displayPayment(ByRef mortgage As MortgageData)
        lblAmount.Text = FormatCurrency(mortgage.Payment, 2)
        ToolTip1.SetToolTip(lblAmount, "Monthly payment is: " & lblAmount.Text)
    End Sub

    Private Sub displayAmortizationTable(ByRef mortgage As MortgageData)

        Dim tableOutput As String

        '***********************************************************************
        'create AmortizationTable here
        'retreive the Amoritization table
        '***********************************************************************

        rtfAmortTable.Text = tableOutput
        ToolTip1.SetToolTip(rtfAmortTable, "Amortization Table for " & mortgage.FullDataString)
    End Sub

#End Region

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial