Work Gross Income Calculation Help

Needing help on overtime calculation to total gross income

Page 1 of 1

3 Replies - 4006 Views - Last Post: 20 April 2009 - 02:57 PM Rate Topic: -----

#1 SHfan09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-April 09

Work Gross Income Calculation Help

Posted 16 April 2009 - 08:19 AM

Okay. I've been working on this code for four days trying to get my overtime form to calculate to the gross income form.

This is the description for the program.
You add your hours worked(hoursworkedDecimal) and hourly pay(hourlypayDecimal). When you click calculate it multipies those two. Now if you check the checkbox "Worked Overtime?" it brings up another form. On that form you have one textbox"overtimeDecimal" with two buttons. A calculate button that should grab the hourlypayDecimal and calculate. The other button "Add to Pay" will add the pay to the first form in the "grossincomeTextBox" 'grossincomeDecimal'.

The program will calculate if I don't check the Overtime checkbox, but when I check the overtime box and click calculate, the overtime form pops up and I type in my overtime hours and click the calculate button and then I click add to pay button. Only that calculation not add to the gross pay.

I hope I did not confuse anyone. I would really really appreciate any help. I think I've already pulled out all my hair working on this.
Thank you.

Public Class grossincomeForm
	Friend hoursworkedDecimal As Decimal
	Friend hourlypayDecimal As Decimal
	Friend grossincomeDecimal As Decimal

	Private Sub calculatepayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculatepayButton.Click
		Dim hoursworkedDecimal As Decimal
		Dim hourlypayDecimal As Decimal
	  
		With Me
			Try
				hoursworkedDecimal = Decimal.Parse(.hoursworkedTextBox.Text)
				hourlypayDecimal = Decimal.Parse(.hourlypayTextBox.Text)

				grossincomeDecimal += (hoursworkedDecimal * hourlypayDecimal)

				'Show a message box if overtime Check box is checked
				If .overtimeCheckBox.Checked = True Then
					overtimeForm.Show()
					MessageBox.Show("Add your overtime hours", "Information")
					grossincomeDecimal += overtimeForm.overtimecalc
				End If

				'Subtract a dollar from gross pay.
				If .unitedwayCheckBox.Checked = True Then
					grossincomeDecimal -= 1
				End If

				'Format and display values.
				grossincomeTextBox.Text = grossincomeDecimal.ToString("C")

			Catch quanityexception As FormatException
				'Handle a price Exception
				MessageBox.Show("Must enter numeric value", "Data Entry Error", _
				MessageBoxButtons.OK, MessageBoxIcon.Warning)
				With Me.hoursworkedTextBox
					.Focus()
					.SelectAll()
				End With
			End Try
		End With
	End Sub

Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
		'Clear the form
		With Me
			.overtimeCheckBox.Checked = False
			With .hoursworkedTextBox
				Me.hourlypayTextBox.Clear()
				'Me.grossincomeTextBox.Clear()
				.Clear()
				.Focus()
			End With
		End With
	End Sub 



Here is the OvertimeForm.
Public Class overtimeForm
	Friend overtimeDecimal As Decimal
	Friend overtimecalc As Decimal
	'Friend grossincomeDecimal As Decimal
	' Friend hourlypayDecimal As Decimal

	Private Sub addpayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addpayButton.Click
		With Me
			overtimeDecimal = Decimal.Parse(Me.overtimeTextBox.Text)

			' Me.overtimecalc = grossincomeForm.grossincomeTextBox
			grossincomeForm.grossincomeDecimal += overtimecalc

		End With

		'tell user amount was calculated to gross pay.
		'  MessageBox.Show("Item calculated to gross income".PadLeft(16), "Information".ToUpper, MessageBoxButtons.OK)

		'close this form when info is added
		Me.Close()
	End Sub

	Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
		Dim overtimecalc As Decimal
		With Me
			overtimecalc = (overtimeDecimal * grossincomeForm.hourlypayDecimal / 2)
		End With
	End Sub
End Class 


Is This A Good Question/Topic? 0
  • +

Replies To: Work Gross Income Calculation Help

#2 microstoc  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 04-April 09

Re: Work Gross Income Calculation Help

Posted 16 April 2009 - 12:29 PM

View PostSHfan09, on 16 Apr, 2009 - 07:19 AM, said:

Okay. I've been working on this code for four days trying to get my overtime form to calculate to the gross income form.

This is the description for the program.
You add your hours worked(hoursworkedDecimal) and hourly pay(hourlypayDecimal). When you click calculate it multipies those two. Now if you check the checkbox "Worked Overtime?" it brings up another form. On that form you have one textbox"overtimeDecimal" with two buttons. A calculate button that should grab the hourlypayDecimal and calculate. The other button "Add to Pay" will add the pay to the first form in the "grossincomeTextBox" 'grossincomeDecimal'.

The program will calculate if I don't check the Overtime checkbox, but when I check the overtime box and click calculate, the overtime form pops up and I type in my overtime hours and click the calculate button and then I click add to pay button. Only that calculation not add to the gross pay.

I hope I did not confuse anyone. I would really really appreciate any help. I think I've already pulled out all my hair working on this.
Thank you.

Public Class grossincomeForm
	Friend hoursworkedDecimal As Decimal
	Friend hourlypayDecimal As Decimal
	Friend grossincomeDecimal As Decimal

	Private Sub calculatepayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculatepayButton.Click
		Dim hoursworkedDecimal As Decimal
		Dim hourlypayDecimal As Decimal
	  
		With Me
			Try
				hoursworkedDecimal = Decimal.Parse(.hoursworkedTextBox.Text)
				hourlypayDecimal = Decimal.Parse(.hourlypayTextBox.Text)

				grossincomeDecimal += (hoursworkedDecimal * hourlypayDecimal)

				'Show a message box if overtime Check box is checked
				If .overtimeCheckBox.Checked = True Then
					overtimeForm.Show()
					MessageBox.Show("Add your overtime hours", "Information")
					grossincomeDecimal += overtimeForm.overtimecalc
				End If

				'Subtract a dollar from gross pay.
				If .unitedwayCheckBox.Checked = True Then
					grossincomeDecimal -= 1
				End If

				'Format and display values.
				grossincomeTextBox.Text = grossincomeDecimal.ToString("C")

			Catch quanityexception As FormatException
				'Handle a price Exception
				MessageBox.Show("Must enter numeric value", "Data Entry Error", _
				MessageBoxButtons.OK, MessageBoxIcon.Warning)
				With Me.hoursworkedTextBox
					.Focus()
					.SelectAll()
				End With
			End Try
		End With
	End Sub

Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
		'Clear the form
		With Me
			.overtimeCheckBox.Checked = False
			With .hoursworkedTextBox
				Me.hourlypayTextBox.Clear()
				'Me.grossincomeTextBox.Clear()
				.Clear()
				.Focus()
			End With
		End With
	End Sub 



Here is the OvertimeForm.
Public Class overtimeForm
	Friend overtimeDecimal As Decimal
	Friend overtimecalc As Decimal
	'Friend grossincomeDecimal As Decimal
	' Friend hourlypayDecimal As Decimal

	Private Sub addpayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addpayButton.Click
		With Me
			overtimeDecimal = Decimal.Parse(Me.overtimeTextBox.Text)

			' Me.overtimecalc = grossincomeForm.grossincomeTextBox
			grossincomeForm.grossincomeDecimal += overtimecalc

		End With

		'tell user amount was calculated to gross pay.
		'  MessageBox.Show("Item calculated to gross income".PadLeft(16), "Information".ToUpper, MessageBoxButtons.OK)

		'close this form when info is added
		Me.Close()
	End Sub

	Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
		Dim overtimecalc As Decimal
		With Me
			overtimecalc = (overtimeDecimal * grossincomeForm.hourlypayDecimal / 2)
		End With
	End Sub
End Class 



Do you really need two forms? It seems to complicate things.
If you don't need two forms then I would have these textboxes on just the one form:

hoursworkedtextbox
overtimehourstextbox
hourlypaytextbox

When the Calc Button is pressed I would then do the calc using this general method (not real code here, just the idea, ok):

grossincomedecimal = 0

grossincomedecimal = hoursworkedtextbox * hourlypaytextbox

Then I would test for any overtime hours that may have been entered:

if overtimehourstextbox > 0 then
'put your correct calculation here
grossincomedecimal = grossincomedecimal + ( overtimehourstextbox * hourlypaytextbox)
end if

grossincometextbox = grossincomedecimal


(Overtime is normally time and a half, or double time. You have it as half the normal hourly rate?)

HTH
Was This Post Helpful? 1
  • +
  • -

#3 SHfan09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-April 09

Re: Work Gross Income Calculation Help

Posted 20 April 2009 - 06:07 AM

View Postmicrostoc, on 16 Apr, 2009 - 11:29 AM, said:

Do you really need two forms? It seems to complicate things.
If you don't need two forms then I would have these textboxes on just the one form:

hoursworkedtextbox
overtimehourstextbox
hourlypaytextbox

When the Calc Button is pressed I would then do the calc using this general method (not real code here, just the idea, ok):

grossincomedecimal = 0

grossincomedecimal = hoursworkedtextbox * hourlypaytextbox

Then I would test for any overtime hours that may have been entered:

if overtimehourstextbox > 0 then
'put your correct calculation here
grossincomedecimal = grossincomedecimal + ( overtimehourstextbox * hourlypaytextbox)
end if

grossincometextbox = grossincomedecimal


(Overtime is normally time and a half, or double time. You have it as half the normal hourly rate?)

HTH


Thank you very much! That helped a lot. I really don't know why I wanted to do 2 forms. But it did complicate things. I've finished the program and even added a few more things to it. Thanks very much! On the overtime, when I went back to edit it I took out a part of the code so it looked like I was dividing from the hourly pay.
Was This Post Helpful? 0
  • +
  • -

#4 microstoc  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 59
  • Joined: 04-April 09

Re: Work Gross Income Calculation Help

Posted 20 April 2009 - 02:57 PM

I'm glad you got it sorted.
Nothing beats the buzz of getting a bit of code to work how you intended.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1