Yay!It's a beauty. I feel like quite the accomplished padawan.
Dim EmployeeName As String Dim OVERTIME As Double Dim ABSENT As Double Dim X As Integer Dim Bonus As Integer EmployeeName = InputBox("Enter name") OVERTIME = InputBox("Enter hours of overtime") ABSENT = InputBox("Enter hours of absenteism") X = OVERTIME - 2 * ABSENT / 3 If X > 40 Then Bonus = 50 ElseIf X > 30 Then Bonus = 40 ElseIf X > 20 Then Bonus = 30 ElseIf X > 10 Then Bonus = 20 Else: Bonus = 10 End If MsgBox ("Bonus payment for " & EmployeeName & " is $" & Bonus)
OK I know this is probably like teaching a child how to count to 10 when you're an astrophysicist but since we're already here and all, I was wondering if you would mind taking a look at my other assignment? The macro works just fine but it could probably be improved.
"Write a VBA macro which adds up the numbers from 0 to n. ‘n’ is the input from the user."
Dim i As Integer, n As Integer Dim ans As Integer n = InputBox("Enter number") ans = 0 i = 1 Do While i <= n ans = ans + i i = i + 1 Loop MsgBox ("Result is" & ans)




It's a beauty. I feel like quite the accomplished padawan.
Reply With Quote