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

Visual Basic Classic

Avatar of undefined
Last Comment
Éric Moreau

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Éric Moreau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes