Results 1 to 9 of 9

Thread: Assistance with MsgBox in Program

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    4

    Exclamation Assistance with MsgBox in Program

    OK, it's the newbie to programming. I have written a program to calcuate and display the montly payment and total interest paid on a loan. I have to put in a note that says if interest rate is below .06 that "Interest Rate Must Be 6% or higher." I don't have a problem with the message but after the message is displayed and I hit ok, it still calculates the amount. How do I get it to either, return to program to input new interest rate then complete program: Code is as follows:
    Code:
    Public Class frmLoan
    
        Private Sub btnAnalyze_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAnalyze.Click
    
            Dim p, r, n, payment, ti As Double
            ' Set MSGbox if percentage is off
            If r < 0.06 Then
                MsgBox("Interest rate must be 6 percent or higher", MsgBoxStyle.Exclamation, "WARNING")
            Else
    
            End If
    
            'set value parameters for calculation
            p = CDbl(txtloan.Text)
            r = CDbl(txtRate.Text) / 12
            n = CDbl(txtLength.Text) ' duration of loan
            payment = (p * r) / (1 - (1 + r) ^ (-n))
            ti = (n * payment) - p
    
    
            'display results from formula calculations
            With lstResults.Items
                .Clear()
                .Add("Total monthly pay is " & (FormatCurrency(payment) & "."))
                .Add("")
                .Add("Total interest is paid is " & (FormatCurrency(ti) & "."))
    
            End With
    
        End Sub
    End Class
    Last edited by Hack; Jul 17th, 2007 at 06:50 AM. Reason: Added [code][/code] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width