| | |
Salary Review project
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Solved Threads: 0
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]
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]
Last edited by neongabby; Jun 25th, 2008 at 3:46 pm.
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
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 doingAnywho, 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.
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#3 17 Days Ago
vb.net Syntax (Toggle Plain Text)
Public Class MainForm Dim crntslry101 As Decimal = 10000 Dim crntslry102 As Decimal = 11500 Dim crntslry103 As Decimal = 12300 Dim raise101 As Decimal Dim raise102 As Decimal Dim raise103 As Decimal 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 prcntRazComboBox101.Items.Add(raise.ToString) Next For raise As Integer = 1 To 10 Step 1 prcntRazComboBox102.Items.Add(raise.ToString) Next For raise As Integer = 1 To 10 Step 1 prcntRazComboBox103.Items.Add(raise.ToString) Next 'display current salaries ShowCurrentSalary() End Sub Private Sub shProjSlryBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles shProjSlryBtn.Click Dim salary As Decimal Dim raise As Integer If (String.Compare(prcntRazComboBox101.Text, "")) Then raise = Convert.ToInt32(prcntRazComboBox101.Text) projslryLbl101.Text = ShowProjection(crntslry101, raise) End If If (String.Compare(prcntRazComboBox102.Text, "")) Then raise = Convert.ToInt32(prcntRazComboBox102.Text) projslryLbl102.Text = ShowProjection(crntslry102, raise) End If If (String.Compare(prcntRazComboBox103.Text, "")) Then raise = Convert.ToInt32(prcntRazComboBox103.Text) projslryLbl103.Text = ShowProjection(crntslry103, raise) End If 'projslryLbl101.Text = raise.ToString("C2") 'projslryLbl102.Text = raise.ToString("C2") 'projslryLbl103.Text = raise.ToString("C2") ShowCurrentSalary() End Sub Private Sub ShowCurrentSalary() slryLbl101.Text = crntslry101.ToString("C2") slryLbl102.Text = crntslry102.ToString("C2") slryLbl103.Text = crntslry103.ToString("C2") End Sub Private Function ShowProjection(ByVal salary As Decimal, _ ByVal raise As Decimal) salary = salary * (1 + (raise * 0.01)) Return salary.ToString("C2") 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 prcntRazComboBox101_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles prcntRazComboBox101.SelectedIndexChanged Dim raise As Integer Dim assign As Boolean 'assign value of selected raise assign = Decimal.TryParse(projslryLbl101.Text, raise) End Sub Private Sub prcntRazComboBox102_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles prcntRazComboBox102.SelectedIndexChanged Dim raise As Integer Dim assign As Boolean 'assign value of selected raise assign = Decimal.TryParse(projslryLbl102.Text, raise) End Sub Private Sub prcntRazComboBox103_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles prcntRazComboBox103.SelectedIndexChanged Dim raise As Integer Dim assign As Boolean 'assign value of selected raise assign = Decimal.TryParse(projslryLbl103.Text, raise) End Sub Private Sub GrntRasBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles GrntRasBtn.Click Dim raise As Integer If (String.Compare(prcntRazComboBox101.Text, "")) Then raise = Convert.ToInt32(prcntRazComboBox101.Text) slryLbl101.Text = ShowProjection(crntslry101, raise) End If If (String.Compare(prcntRazComboBox102.Text, "")) Then raise = Convert.ToInt32(prcntRazComboBox102.Text) slryLbl102.Text = ShowProjection(crntslry102, raise) End If If (String.Compare(prcntRazComboBox103.Text, "")) Then raise = Convert.ToInt32(prcntRazComboBox103.Text) slryLbl103.Text = ShowProjection(crntslry103, raise) End If End Sub Private Sub clrProjBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles clrProjBtn.Click projslryLbl101.Text = "" projslryLbl102.Text = "" projslryLbl103.Text = "" End Sub Private Sub exitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitBtn.Click Me.Close() End Sub End Class
Last edited by peter_budo; 16 Days Ago at 7:25 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: ContextMenuStrip
- Next Thread: VB 2008 & Database Issues
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dropdownlist excel fade file-dialog folder ftp generatetags google hardcopy image images input insert intel internet mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial shutdown soap string survey table tcp temperature text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





