|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: |
Option Explicit On
Imports System.Data
Imports System.Collections
Imports System.Collections.Generic
Public Class MortgageForm
Private Sub MortgageForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Declare new list
Dim LoanOpList As New List(Of String)
'Add items to the list
LoanOpList.Add("Choose a Loan")
LoanOpList.Add("7 Years @ 5.35%")
LoanOpList.Add("15 Years @ 5.5%")
LoanOpList.Add("30 Years @ 5.75%")
'set list as the data source for the combo box
ComboBox1.DataSource = LoanOpList
End Sub
Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
Dim decRate() As Decimal = {0.004458333, 0.00458333, 0.004791666} 'declare and initialize array
Dim intTerm() As Integer = {84, 180, 360} 'declare and initialize array
Dim intPymtTerm As Integer
Dim decPrincipal As Decimal = 0 'declare and initialize principal value
Dim decPayment, decIntPd, decPrinPd, decPymtRate, decBal As Decimal
Try
Decimal.TryParse(Me.txtPrincipal.Text, decPrincipal)
If (decPrincipal <= 0) Then 'checks if decimal is entered
MessageBox.Show("Please Enter a Valid Loan Amount", "Invalid Data!") 'displays error message to user
Me.txtPrincipal.Clear() 'clears principal text box
Me.txtPrincipal.Focus() 'sets focus to principal text box
Exit Sub 'exits sub
End If
'rate term will be set to the chosen array value
If ComboBox1.SelectedIndex = 0 Then
MessageBox.Show("Please Choose a Loan Option", "Alert!")
Exit Sub
End If
If ComboBox1.SelectedItem = "7 Years @ 5.35%" Then
decPymtRate = decRate(0)
intPymtTerm = intTerm(0)
ElseIf ComboBox1.SelectedItem = "15 Years @ 5.5%" Then
decPymtRate = decRate(1)
intPymtTerm = intTerm(1)
ElseIf ComboBox1.SelectedItem = "30 Years @ 5.75%" Then
decPymtRate = decRate(2)
intPymtTerm = intTerm(2)
End If
'Calculates the monthly payment
decPayment = (decPrincipal * decPymtRate) / (1 - Math.Pow(1 + decPymtRate, -intPymtTerm))
'formats payment to currency
Me.lblPymtAmt.Text = FormatCurrency(decPayment)
'Declare and instantiate List
Dim AmortizationList As New List(Of mortgage)
Dim i As Integer ' declare loop variable
For i = 1 To intPymtTerm 'Will loop to print out amortization
'set interest
decIntPd = decPrincipal * decPymtRate
'set loan amount
decPrinPd = decPayment - decIntPd
'set balance
decBal = decPrincipal - decPrinPd
'set remaining principal owed
decPrincipal = decBal
'Adds amortization data to the DataGridView control
AmortizationList.Add(New mortgage(i, decPrinPd, decIntPd, decBal))
Next
'Binds data source to the AmortizationList
Me.MortgageBindingSource.DataSource = AmortizationList
Me.MortgageDataGridView.DataSource = Me.MortgageBindingSource
Catch ex As Exception 'Prevents program from crashing
MessageBox.Show(ex.Message.ToString, "Error Handling", MessageBoxButtons.OK)
End Try
End Sub
Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
lblPymtAmt.Text = "" 'clears text from the label that displays payment
MortgageDataGridView.Rows.Clear() 'clears the DataGrid control
ComboBox1.SelectedItem = "7 Years @ 5.35%" 'sets ComboBox control to 1st option
Me.txtPrincipal.Focus()
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close() 'exits program when exit button is clicked
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
End Class
|
Advertisement
| Hall of Fame |