# VB opinion plz

#### Charlie

##### Board Regular
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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

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%)

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?

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

count yourself lucky some of us don't get overtime of any sort...

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

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 ...............

Replies
3
Views
376
Replies
7
Views
401
Replies
2
Views
440
Replies
4
Views
568
Replies
4
Views
502

1,221,209
Messages
6,158,550
Members
451,498
Latest member
tyshanklin1

### 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.

### Which adblocker are you using?

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

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