943,965 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1172
  • VB.NET RSS
Jun 25th, 2008
0

Salary Review project

Expand Post »
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]
Attached Files
File Type: doc Salary Review.doc (53.5 KB, 21 views)
Last edited by neongabby; Jun 25th, 2008 at 3:46 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
neongabby is offline Offline
1 posts
since Jun 2008
Nov 7th, 2009
0

know what's wrong - not sure yet how to resolve

Click to Expand / Collapse  Quote originally posted by neongabby ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
oldyeller85 is offline Offline
2 posts
since Oct 2009
Nov 7th, 2009
0
Re: Salary Review project
vb.net Syntax (Toggle Plain Text)
  1. Public Class MainForm
  2. Dim crntslry101 As Decimal = 10000
  3. Dim crntslry102 As Decimal = 11500
  4. Dim crntslry103 As Decimal = 12300
  5. Dim raise101 As Decimal
  6. Dim raise102 As Decimal
  7. Dim raise103 As Decimal
  8.  
  9.  
  10. Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  11. 'add raise amounts to combo boxes
  12.  
  13. For raise As Integer = 1 To 10 Step 1
  14. prcntRazComboBox101.Items.Add(raise.ToString)
  15. Next
  16. For raise As Integer = 1 To 10 Step 1
  17. prcntRazComboBox102.Items.Add(raise.ToString)
  18. Next
  19. For raise As Integer = 1 To 10 Step 1
  20. prcntRazComboBox103.Items.Add(raise.ToString)
  21. Next
  22.  
  23. 'display current salaries
  24. ShowCurrentSalary()
  25.  
  26. End Sub
  27. Private Sub shProjSlryBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  28. Handles shProjSlryBtn.Click
  29. Dim salary As Decimal
  30. Dim raise As Integer
  31. If (String.Compare(prcntRazComboBox101.Text, "")) Then
  32. raise = Convert.ToInt32(prcntRazComboBox101.Text)
  33. projslryLbl101.Text = ShowProjection(crntslry101, raise)
  34. End If
  35. If (String.Compare(prcntRazComboBox102.Text, "")) Then
  36. raise = Convert.ToInt32(prcntRazComboBox102.Text)
  37. projslryLbl102.Text = ShowProjection(crntslry102, raise)
  38. End If
  39. If (String.Compare(prcntRazComboBox103.Text, "")) Then
  40. raise = Convert.ToInt32(prcntRazComboBox103.Text)
  41. projslryLbl103.Text = ShowProjection(crntslry103, raise)
  42. End If
  43.  
  44.  
  45. 'projslryLbl101.Text = raise.ToString("C2")
  46. 'projslryLbl102.Text = raise.ToString("C2")
  47. 'projslryLbl103.Text = raise.ToString("C2")
  48.  
  49. ShowCurrentSalary()
  50.  
  51. End Sub
  52. Private Sub ShowCurrentSalary()
  53. slryLbl101.Text = crntslry101.ToString("C2")
  54. slryLbl102.Text = crntslry102.ToString("C2")
  55. slryLbl103.Text = crntslry103.ToString("C2")
  56.  
  57. End Sub
  58. Private Function ShowProjection(ByVal salary As Decimal, _
  59. ByVal raise As Decimal)
  60.  
  61. salary = salary * (1 + (raise * 0.01))
  62. Return salary.ToString("C2")
  63.  
  64. End Function
  65. Private Function GrantRaise(ByRef salary As Decimal, _
  66. ByRef raise As Decimal)
  67.  
  68. salary = salary * (1 + (raise * 0.01))
  69. Return salary
  70. End Function
  71.  
  72. Private Sub prcntRazComboBox101_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  73. Handles prcntRazComboBox101.SelectedIndexChanged
  74. Dim raise As Integer
  75. Dim assign As Boolean
  76.  
  77. 'assign value of selected raise
  78. assign = Decimal.TryParse(projslryLbl101.Text, raise)
  79.  
  80. End Sub
  81. Private Sub prcntRazComboBox102_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  82. Handles prcntRazComboBox102.SelectedIndexChanged
  83. Dim raise As Integer
  84. Dim assign As Boolean
  85.  
  86. 'assign value of selected raise
  87. assign = Decimal.TryParse(projslryLbl102.Text, raise)
  88.  
  89. End Sub
  90. Private Sub prcntRazComboBox103_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  91. Handles prcntRazComboBox103.SelectedIndexChanged
  92. Dim raise As Integer
  93. Dim assign As Boolean
  94.  
  95. 'assign value of selected raise
  96. assign = Decimal.TryParse(projslryLbl103.Text, raise)
  97.  
  98. End Sub
  99.  
  100. Private Sub GrntRasBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  101. Handles GrntRasBtn.Click
  102. Dim raise As Integer
  103. If (String.Compare(prcntRazComboBox101.Text, "")) Then
  104. raise = Convert.ToInt32(prcntRazComboBox101.Text)
  105. slryLbl101.Text = ShowProjection(crntslry101, raise)
  106. End If
  107. If (String.Compare(prcntRazComboBox102.Text, "")) Then
  108. raise = Convert.ToInt32(prcntRazComboBox102.Text)
  109. slryLbl102.Text = ShowProjection(crntslry102, raise)
  110. End If
  111. If (String.Compare(prcntRazComboBox103.Text, "")) Then
  112. raise = Convert.ToInt32(prcntRazComboBox103.Text)
  113. slryLbl103.Text = ShowProjection(crntslry103, raise)
  114. End If
  115. End Sub
  116.  
  117.  
  118. Private Sub clrProjBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  119. Handles clrProjBtn.Click
  120. projslryLbl101.Text = ""
  121. projslryLbl102.Text = ""
  122. projslryLbl103.Text = ""
  123. End Sub
  124.  
  125. Private Sub exitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitBtn.Click
  126. Me.Close()
  127. End Sub
  128.  
  129.  
  130. End Class
Last edited by peter_budo; Nov 8th, 2009 at 7:25 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
oldyeller85 is offline Offline
2 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: ContextMenuStrip
Next Thread in VB.NET Forum Timeline: VB 2008 & Database Issues





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC