VB opinion plz

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
Hi,
I am building an APP that will accept the hours worked and hourly rate for an employee.
The normal working week is 40 hours, with any additional worked hours classed as overtime.
Overtime is paid as
up to 10 hours above 40 = time and a half
any additional hours so that would be 50 or more hours worked = Double time.

Ive coded this APP and to me it works fine apart from the final amount not being in a cash value.
Could someone look to see if I have gotten the equation correct before I start opening the champagne.

Option Explicit

Private Sub cmdQUIT_Click()
'Terminate Application
End
End Sub

Private Sub cmdStart_Click()
'Declare required storage
Dim Hours_Wrk As Integer
Dim Hourly_Rate As Currency
Dim Total As Currency
Dim Wrk_Wk As Integer

'Invite user to input rate and hours
Hours_Wrk = InputBox("Please input hours worked ", "Hours")
Hourly_Rate = InputBox("Please input rate of pay ", "Rate")
Wrk_Wk = 40
If Hours_Wrk = Wrk_Wk Then
Total = Hours_Wrk * Hourly_Rate
ElseIf Hours_Wrk > Wrk_Wk<= 50 Then
Total = Hours_Wrk * Hourly_Rate * 1.5
Else
If Hours_Wrk > 50 Then
Total = Hours_Wrk * Hourly_Rate * 2
End If
End If


'Display output in pic box
picMessage.Print "The hours worked are " & (Hours_Wrk)
picMessage.Print "The rate per hour is " & (Hourly_Rate)
picMessage.Print "The total pay is " & "£"; (Total)










End Sub



Thanks
Charlie
This message was edited by Charlie on 2002-10-18 12:14
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
you need to adapt your ifs to include the various possibilities...

i.e.

if Wrk_Wk less than or equal to 40 then 40 * normal rate

if Wrk_Wk greater than 50 then total
40 * normal rate plus
10 * (normal rate * 150%) plus
Wrk_Wk - 50 * (normal rate * 200%) (can't remember the rate off hand)

if Wkr_Wk greater than 40 and less than 50 then TOTAL
40 * normal rate
Wrk_Wk - 40 * (normal rate * 150%)
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Can I come and work for you? If I work more than 40 hours I get all the hours at time and a half. But on the downside I'm not sure I would ever get any double time.

Code:
If Hours_Wrk = Wrk_Wk Then 
   Total = Hours_Wrk * Hourly_Rate 
ElseIf Hours_Wrk > Wrk_Wk Then 
   If Hours_Wrk > 50 Then 
      Total = Wrk_Wk * Hourly_Rate
      Total = Total + (10 * Hourly_Rate * 1.5)
      Total = Total + ((Hours_Wrk-50) * Hourly_Rate * 2)
    Else
      Total = Wrk_Wk * Hourly_Rate
      Total = Total + ((Hours_Wrk-40) * Hourly_Rate * 1.5)
    End If
End If

What happens if I work less than 40 hours - no pay at all?
 

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
Ive adapted mine to show what I think it should look like.
It looks right to me.
I cant be wrong not again.
And I thought I had completed an APP that worked properly on my own.
****.
Charlie
 

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
count yourself lucky some of us don't get overtime of any sort...

that said, 5.30 Friday night, time for the pub.
 

Jack in the UK

Well-known Member
Joined
Feb 16, 2002
Messages
3,215
Overt-ime ??? I looked that up in the dictionary ??? not in there, asked my boss he asked the MD he did not know.

I doubt i can spell it !!! ????

Checked the internet and it say Extra work above and boyond the call of duty and never in contract for no monitory gains...

So does that mean Jackworks for sod all - i never have lunch or thats what some guys i work for say and talk about, check the dictonary and ...............
 

Forum statistics

Threads
1,144,307
Messages
5,723,629
Members
422,505
Latest member
Noar33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top