Overclock.net banner

1 - 15 of 15 Posts

·
Registered
Joined
·
800 Posts
Discussion Starter · #1 ·
Is anyone familiar with Microsoft Visual Basics and strings? I am taking a Visual Basics course and really need some help as I'm having problems doing an assignment. It is an introduction course so it is some basic stuff that would probably be simple to you guys but I'm stuck on how to do something right now.
 

·
Registered
Joined
·
3,233 Posts
Show us what you need help with first, and someone will help you. We just won't do your homework for you.
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #3 ·
I wasn't hoping for someone to do it for me. I was hoping that whoever was willing to help me would go on aim or in a vent server to help me more effectively. Once I get home from my classes today I will post some of it so you get an idea.
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #4 ·
If someone would be willing to help...I would greatly appreciate it. Basically I have to create a monthly loan payment calculator with For Loop on Visual Basic. I think I've finally figured out how to do For Loop but for some reason can't get the arithmetic to work...if you have vent, ts3, or AIM that would be even better. I wouldn't even know where to start explaining on here
 

·
Registered
Joined
·
3,233 Posts
I can't get into vent or anything tonight (because I'm actually programming, ironically). But if you show me the code you have so far, I can walk you through the problem(s).
 

·
Registered
Joined
·
72 Posts
I wont do it for you (as that defeats the purpose of taking the class) but I can definitely help you. PM me if you need any help.
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #7 ·
Ok well I'm going to post s/s so you can see my work. I'm very new to this so my code will be far from excellent. As I said before, I got the loop to work but I am not sure how to get my arithmetic right...I believe I have a value that is wrong somewhere or placed in the wrong spot but can't figure it out. I think one of them has to deal with the principle amount because the value should start off at 160,000 and be decreasing but that is not the case.

sc49c2.jpg


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Loan, Interest, Years As Single
Dim Numberpayments, Monthlyrate, Monthlypayment As Single
Dim Interestpart, Principlepart, Balance, Principle As Single
Dim Paymentoutput As String
Loan = Val(TextBox1.Text)
Interest = Val(TextBox2.Text)
Years = Val(TextBox3.Text)
Dim count As Single
Numberpayments = Years * 12
Monthlyrate = 1 + (Interest / (12 * 100))
Monthlypayment = (Loan * Interest * Monthlyrate ^ Numberpayments) / (1200 * ((Monthlyrate ^ Numberpayments) - 1))
Interestpart = Principle * (Interest * 0.01) / 12
Principlepart = Monthlypayment - Interestpart
Principle = Loan - Principlepart
Balance = Principle - Principlepart
For count = 1 To Numberpayments
Paymentoutput = Paymentoutput & "Payment #" & count & vbTab & _
Format(Principle, "C") & " " & vbTab & FormatCurrency(Interestpart) & vbTab & _
FormatCurrency(Principlepart) & vbTab & FormatCurrency(Balance) & vbCrLf
Next count
TextBox4.AppendText("Payment Period" & vbTab & "Current Principle" & vbTab & "Interest" & vbTab & "Principle" & vbTab & vbTab & "Balance" & vbNewLine & Paymentoutput)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = Nothing
TextBox2.Text = Nothing
TextBox3.Text = Nothing
TextBox4.Text = Nothing
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #8 ·
These are the details for the assignment.

This assignment will allow a user to enter:

Enter the amount of a loan (known as the principle, money to be borrowed)
An interest rate of the loan (i.e. 8, 9.5, 10.25, or 11.4)
Number of years for this loan (i.e. 5, 10, 15, 30)
Compute the monthly payment of a loan and determine the interest and principle portions for this month's payment

We will need a series of intermediate calculations:

Total Number of Payments = Number of years X 12
monthlyrate = 1 + (interest / (12 * 100))
monthlypayment = (Loan * interest * monthlyrate ^ Numberpayments) / (1200 * ((monthlyrate ^ Numberpayments) - 1)

The number of payment periods runs from 1 to 360. Each payment consists of interest on the balance of the loan and a principle repayment. The interest will decline, the principle portion increases. The falling interest portion is a smaller rate based on a smaller unpaid principle balance.

Within a For loop ( For count = 1 To Numberpayments)

interestpart = principle * (interest * 0.01) / 12

principlepart = monthlypayment - interestpart

balance = principle - principlepart


The Payment Period, the current principle, interestpart, principlepart and the balance should be printed.


The output is stored in a string:

paymentoutput = paymentoutput & "Payment #" & count & vbTab & _

Format(principle, "C") & " " & vbTab & FormatCurrency(interestpart) & vbTab & _ FormatCurrency(principlepart) & vbTab & FormatCurrency(balance) & vbCrLf


The current principle becomes the balance (principle = balance)
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #10 ·
I think I solved one of the errors I have so now I finally get interestpart. Changed the code to....

Monthlypayment = (Loan * Interest * Monthlyrate ^ Numberpayments) / (1200 * ((Monthlyrate ^ Numberpayments) - 1))
Principle = Loan - Principlepart
Interestpart = Principle * (Interest * 0.01) / 12
Principlepart = Monthlypayment - Interestpart
Balance = Principle - Principlepart

Basically I changed principle so that it's before interestpart. I'm not sure how to get my arithmetic to work in the loop to that it continues to keep calculating the monthly payments...
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #12 ·
Quote:
Originally Posted by Teppich;15257017
Im finishing up an assignment then Ill take a look.
Thanks. I've seriously been at this the entire day. Most of the time I would be stuck and make little progress in between but now I feel completely stuck.

edit: So frustrating...I can't figure out how to loop the function. The function just keeps calculating the same values.
 

·
Registered
Joined
·
72 Posts
You werent updating some of the variables inside the loop, hopefully what I sent you will help. Also, decimal is problem the better data type (instead of single). Just realized you were using a textbox to print out the values, sorry if the listbox confuses you.
 

·
Registered
Joined
·
800 Posts
Discussion Starter · #14 ·
Quote:
Originally Posted by Teppich;15257423
You werent updating some of the variables inside the loop, hopefully what I sent you will help. Also, decimal is problem the better data type (instead of single). Just realized you were using a textbox to print out the values, sorry if the listbox confuses you.
Oh I just realized. I believe we have not learned listbox yet and the teacher wants us to do it through the textbox. Do you know how to get the values to work through textbox?
 
1 - 15 of 15 Posts
Top