Hi all,
I am extremely new to vb.net. I've been mucking around with the below project. I have also attached the original instructions to give you a better idea of what I'm supposed to be doing :) Anywho, here is my code. given that I don't get the results I want, I know my code is messed up somewhere:
[code]Public Class mainForm Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'add raise amounts to combo boxes For raise As Integer = 1 To 10 Step 1 ComboBox1.Items.Add(raise.ToString) Next For raise As Integer = 1 To 10 Step 1 ComboBox2.Items.Add(raise.ToString) Next For raise As Integer = 1 To 10 Step 1 ComboBox3.Items.Add(raise.ToString) Next
'display current salaries Call ShowCurrentSalary()
End Sub Private Function ShowProjection(ByVal salary As Decimal, _ ByVal raise As Decimal)
salary = salary * (1 + (raise * 0.01)) Return salary
End Function Private Function GrantRaise(ByRef salary As Decimal, _ ByRef raise As Decimal)
salary = salary * (1 + (raise * 0.01)) Return salary End Function Private Sub ShowCurrentSalary() Dim currentsalary1 As Decimal = 10000 Dim currentsalary2 As Decimal = 11500 Dim currentsalary3 As Decimal = 12300
current1Label.Text = currentsalary1.ToString("C2") current2Label.Text = currentsalary2.ToString("C2") current3Label.Text = currentsalary3.ToString("C2")
End Sub
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click Me.Close() End Sub
Private Sub clearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearButton.Click projected1Label.Text = String.Empty projected2Label.Text = String.Empty projected3Label.Text = String.Empty End Sub
Private Sub projectedButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles projectedButton.Click Dim salary As Decimal Dim raise As Integer
Call ShowProjection(salary, raise)
projected1Label.Text = raise.ToString("C2") projected2Label.Text = raise.ToString("C2") projected3Label.Text = raise.ToString("C2")
Call ShowCurrentSalary()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Dim raise As Integer Dim assign As Boolean
'assign value of selected raise assign = Decimal.TryParse(projected1Label.Text, raise)
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged Dim raise As Integer Dim assign As Boolean
'assign value of selected raise assign = Integer.TryParse(projected2Label.Text, raise) End Sub
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged Dim raise As Integer Dim assign As Boolean
'assign value of selected raise assign = Decimal.TryParse(projected3Label.Text, raise) End Sub
Private Sub grantButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grantButton.Click Dim salary As Decimal Dim raise As Integer
Call GrantRaise(salary, raise)
current1Label.Text = salary.ToString("C2") current2Label.Text = salary.ToString("C2") current3Label.Text = salary.ToString("C2")
Call ShowCurrentSalary() End Sub End Class[\code]
____
salary was never assigned a value
If I figure this out I'll post the solution.