DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Visual Basic 2008 Mortgage Calculator

  1. #1
    Join Date
    Nov 2009
    Posts
    9

    Visual Basic 2008 Mortgage Calculator

    Hi, I have a school project in which I must complete a mortgage calculator in Visual Basic. I have made the calculator, and it displays the result, but the only issue is that the value is incorrect. I am new to programming, so maybe someone could help me. Here is my code.

    Public Class Form1
    Dim InitialAmount, DownPayment, Interest, PaymentPeriod, Payment As Double
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    InitialAmount = Val(TextBox1.Text)
    DownPayment = Val(TextBox2.Text)
    Interest = Val(TextBox3.Text)
    PaymentPeriod = Val(TextBox4.Text)
    Payment = Val(TextBox5.Text)

    TextBox5.Text = Pmt(Interest, PaymentPeriod * 48, -InitialAmount)
    End Sub
    End Class

  2. #2
    Join Date
    Jun 2009
    Posts
    135
    Wrong forum, you need the .NET forum...

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Moved From Classic VB

    The value is incorrect how?

  4. #4
    Join Date
    Nov 2009
    Posts
    9
    Quote Originally Posted by Hack View Post
    Moved From Classic VB

    The value is incorrect how?
    For example, if I am supposed to recieve a monthly payment of $699.21, my payment on my calculator will say $750. It is usually about $50 off from the appropriate amount. Additionally, does someone know how I could incorporate down payment into the pmt formula?

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Walk me through the process.

    You have these textboxes:

    Textbox1.Text
    Textbox2.Text
    Textbox3.Text
    Textbox4.Text
    Textbox5.Text

    You have these variables:

    InitialAmount
    DownPayment
    Interest
    PaymentPeriod
    Payment

    You are doing this with them
    Code:
    InitialAmount = Val(TextBox1.Text)
    DownPayment = Val(TextBox2.Text)
    Interest = Val(TextBox3.Text)
    PaymentPeriod = Val(TextBox4.Text)
    Payment = Val(TextBox5.Text)
    Now, I have $699.21 - what do I do with it? What textbox does it go in, and what happens to it after I put it there? How does your calculator arrive at $750? What is the math function that is performed on my $699.21?

  6. #6
    Join Date
    Nov 2009
    Posts
    9
    Quote Originally Posted by Hack View Post
    Walk me through the process.

    You have these textboxes:

    Textbox1.Text
    Textbox2.Text
    Textbox3.Text
    Textbox4.Text
    Textbox5.Text

    You have these variables:

    InitialAmount
    DownPayment
    Interest
    PaymentPeriod
    Payment

    You are doing this with them
    Code:
    InitialAmount = Val(TextBox1.Text)
    DownPayment = Val(TextBox2.Text)
    Interest = Val(TextBox3.Text)
    PaymentPeriod = Val(TextBox4.Text)
    Payment = Val(TextBox5.Text)
    Now, I have $699.21 - what do I do with it? What textbox does it go in, and what happens to it after I put it there? How does your calculator arrive at $750? What is the math function that is performed on my $699.21?
    When the result is calculated, it is displayed as TextBox5.Text. The formula I am using to calculate the monthly payment is:

    TextBox5.Text = Pmt(Interest, PaymentPeriod * 48, -InitialAmount)

    Since I am new to programming, I doubt this Pmt function is entirely correct, I just can't find what is wrong with it that always gives me a wrong result.

Similar Threads

  1. Visual Basic 2008 and Sharpoint
    By binnymann in forum Database
    Replies: 3
    Last Post: 04-17-2008, 01:20 PM
  2. Replies: 6
    Last Post: 03-01-2006, 11:08 AM
  3. Book Reviews: "Programming the Web with Visual Basic .NET"
    By Constance J. Petersen in forum dotnet.announcements
    Replies: 0
    Last Post: 11-22-2002, 11:40 AM
  4. New Apress book by DevX section leader -- Bargain Error Price on BarnesAndNoble.com
    By Constance J. Petersen in forum dotnet.announcements
    Replies: 0
    Last Post: 07-26-2002, 03:32 PM
  5. New Site For Visual Basic Developers
    By Paul R. Wilde in forum vb.announcements
    Replies: 0
    Last Post: 08-13-2000, 08:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center