My assignment is to get the
Get Monthly Income (Num1)
Get Monthly Home Rent/Mortgage (Num2)
Get Other Monthly Payments (alimony, child support, student loans) (Num3)
Display Allowable Monthly Car Payment
Display Maximum Car Value (interest rate based on credit) (answer)

``````Public Class Form1

Dim Num1 As Integer
Dim Num2 As Integer
Dim Num3 As Integer
Dim debt As Integer
Dim monthly As Integer
Dim Answer As Integer

Private Sub Buttonsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsubmit.Click
Num1 = TextboxNum1.Text ' This will get the users monthly income
Num2 = TextboxNum2.Text ' This will get the monthly home/rent mortgage
Num3 = TextboxNum3.Text ' this will get any other monthly payments
debt = 0.36 * Num1 ' I can not charge more then 36% of the users monthly income
monthly = debt - Num2 - Num3 ' now I subtract the debts

' this is where I need help, below is part of the code I need for the credit report, (I dont know how to code the percentage for the radiobuttons)
'I need to be able to check one of the three radiobuttons to see how good the credit  the user has (it be 10%, 16%, or 23%)
' and after that I will put the credit (one of the radiobuttons) times it by 6 years, and then times it by how much the user can afford (monthly), and this will display the maximum car value
' Im just stuck on how to code the radiobuttons so they can produce a percentage ( the 10%, 16%, and the 23%) and how to get the how to finish the rest of the code

End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles badcredit.CheckedChanged
If badcredit.Checked = True Then
' I dont know what to do to put this as 23 %
Else
If okcredit.Checked = True Then
' This needs to be 16%
Else
If goodcredit.Checked = True Then
' and this needs to be 10%
End If
End If
End If
End Sub
End Class``````

This is my example that I have to use (the money for the income, rent, and other monthly payments the user entered already)

1. If there monthly Income is: \$2,000.00
2. Monthly Home Rent/Mortgage: \$500.00
3. Other Monthly Payments (alimony, child support, student loans): \$100.00

4. Then there allowable Monthly Car Payment:
( 36% of 2,000 (income) = 720)
( now I subtract debts 720 - 500 (rent) - 100 (other) = \$120

5. Display Maximum Car Value (interest rate based on credit):
Present Value Function (16% per year (this is where I check one of the boxes for the credit, which in this case its an ok credit), 6 years (I have to keep it at 6 years), 120 (this is the allowable monthly car payment) per month)

So basically PV((0.16 / 12), (6 * 12), 120) : \$5532.03

Can someone help me with the radiobuttons and input it to get the answer, ive showed as much as I know how to do, I just dont know how to finish the assignment

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by codeorder

Here's something for starters to get your RadioButtons working properly.

``````Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles rbBadCredit.CheckedChanged, rbOkCredit.CheckedChanged, rbGoodCredit.CheckedChanged
If rbBadCredit.Checked = True Then
' I dont know what to do to put this as 23 %
End If
If rbOkCredit.Checked = True Then
' This needs to be 16%
End If
If rbGoodCredit.Checked = True Then
' and this needs to be 10%
End If
End Sub``````

As for the rest, your entire post is a bit confusing to try and figure out where you need help at. Please supply information that a non-accountant could understand, and I will try and help.

Ok I see what your saying about the radiobuttons working properly, I needed to add the other two radiobuttons. But im not trying to make this hard or anything, what I cant figure out is if the user checks on one of the radio button lets say the bad credit one (rbBadCredit) then the program will recognize that it needs to 23 % (or .23) and puts it into the equation to finish the highest price car the user can buy
Im not trying to make this into something accounting or anything like that. Im just trying to get what the highest car value a user can buy, basically how much can he afford on a car.

If his monthly Income is only \$2,000.00 (this will be inputed in Num1 by the user), I need to times this by 36% (because the assignment says I have to allow him to keep some of his money lol)
Ok now I times \$2000 by 36% to equal to 720
Now I need to figure out his monthly rent (user inputs it into Num2) and other monthly payments (and user inputs it into Num3)
The user puts for his Monthly Home Rent/Mortgage \$500.00 and any other Monthly Payments (alimony, child support, student loans) \$100.00

So now we figure out his allowable monthly Car Payment and to do this we
subtract all his debts from his allowed monthly income
720 (allowed monthly income) - 500 (rent) - 100 (other) = \$120 (this is his allowed monthly car payment)

ok now we got this we need to find his maximum car value (basically how expensive a car he can buy)
To do this (and this is where I am having the problems, because I don’t know how to code the radiobuttons) the user will click on one of the radiobuttons, each one has a different percentage
Because this guy has ok credit, he clicked the ok credit radio button (16%)
Now to find the maximum car value (the most expensive car he can buy)
I think my example answer is wrong, but im suppose to times (what where the user checks as there credit) 16% by 6 years and by there allowed monthly car payments, to find what the most expensive car the user can buy, but I don’t know how to code this right either. The example says this
((0.16 / 12), (6 * 12), 120) : \$5532.03, which I don’t know how they came up with that answer, but ok
All I need is to show that everything works without bugs in it, basically a working code and it produces an answer that looks right, hes just looking for the program to run right and thats really it, messed up math is not going to bother him, he just wanted to make sure the code runs and it asks for the users info, times the monthly income by 36%, the user checks one of the radio buttons and make sure they are used correctly and they also have an if end else in it and then the code produces an answer and that’s all he is really looking for

First off, I renamed the declared Variables from "NumThis/NumThat" to be more appropriate.
I also renamed the controls as well and added code for TextBoxes to be Numeric.
3 TextBoxes(txtIncomeTotal, txtHousingTotal, txtOtherTotal)
1 Button(btnSubmit)

``````Public Class Form1
Private dIncomeTotal, dHousingTotal, dOtherTotal, dDebt, dMonthlyAvailableTotal, dCreditPercentage, dAnswer As Decimal

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'//--- make sure TextBox values are NOT empty, else "Exit Sub" and skip the rest of the code in this Sub.
If txtIncomeTotal.Text = "" Then : MsgBox("Please enter a Monthly Income Total.") : txtIncomeTotal.Select() : Exit Sub : End If
If txtHousingTotal.Text = "" Then : MsgBox("Please enter a Monthly Housing Total.") : txtHousingTotal.Select() : Exit Sub : End If
If txtOtherTotal.Text = "" Then : MsgBox("Please enter a All Other Monthly Total.") : txtOtherTotal.Select() : Exit Sub : End If
'---------\\
'//------ Now that you have values in all TextBoxes, you can proceed. ---------\\
dIncomeTotal = CDec(txtIncomeTotal.Text) '// CDec ='s Convert to Decimal since .Text is a String.
dHousingTotal = CDec(txtHousingTotal.Text)
dOtherTotal = CDec(txtOtherTotal.Text)
dDebt = CDec(0.36 * dIncomeTotal)
dMonthlyAvailableTotal = dDebt - dHousingTotal - dOtherTotal
'// Display result for Total Available Spendings.
MsgBox(FormatCurrency(dMonthlyAvailableTotal.ToString)) '// FormatCurrency formats a # to currency format.
'//========== most expensive car the user can buy ===============\\
'//----- This part is completely wrong or the user is better off buying a bike. :D
'((0.16 / 12), (6 * 12), 120) : \$5532.03
dAnswer = CDec((dCreditPercentage / 12) * (6 * 12) + 120)
'-------------\\
MsgBox(FormatCurrency(dAnswer.ToString)) '// Display result.
End Sub
'// Numeric TextBoxes.
Private Sub myCoolTextBoxes_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles txtIncomeTotal.KeyPress, txtHousingTotal.KeyPress, txtOtherTotal.KeyPress
e.Handled = True '// block all keys.
If Char.IsNumber(e.KeyChar) Then e.Handled = False '// if a #, allow key.
'//--------------------------  CType(sender, TextBox) gets the TextBox "sender" that is sending.
If e.KeyChar = "." AndAlso Not CType(sender, TextBox).Text.Contains("."c) Then e.Handled = False '// if dot, and not already in TextBox, allow key.
If e.KeyChar = "," Then e.Handled = False '// if comma, allow key.
End Sub

Private Sub myCoolRadioButtons_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles rbBadCredit.CheckedChanged, rbOkCredit.CheckedChanged, rbGoodCredit.CheckedChanged
'// I added a "dCreditPercentage" to your Declarations and depending on option selected, the value changes.
If rbBadCredit.Checked Then dCreditPercentage = CDec(0.23)
If rbOkCredit.Checked Then dCreditPercentage = CDec(0.16)
If rbGoodCredit.Checked Then dCreditPercentage = CDec(0.1)
End Sub
End Class``````

Everything seems to be in order except for getting the "most expensive car the user can buy" Total, which I attempted to figure out, but ended up with a different price than "\$5532.03", actually a lot different.

If you need any help understanding any of the code provided do let me know, but I hope the provided comment lines will take care of most of the questions.

Good luck with getting the user into a car and not sending him to buy a skateboard instead. At least I got him on a bike.:D

Yeah but I think it’s a lil to cold for a bike right now lol, but thank you for helping, you’re the most help ive had in a while trying to figure this stuff out. I just got two questions thou. On line 21, the 120 part, did you take that from the example I gave you? Because the 120 was from the example, it was after the monthly income ( after timesing it by 36%) then minus the deductions (rent and other) and that how they came up with 120, I don’t know if you put 120 there for a different reason or you thought that 120 was suppose to be permant? And also if you could list the (I don’t know how to ask this but) like how many textboxes and buttons you used and the names for each one are. So I can stop having all these errors come up

All the controls you need with the proper names are posted in my previous post.
The text that is in bold has: # of controls of same type(name of each control of that type).