Ok, so I am about to finalize my work and need help with the final step.
So far I have 2 Function with a sub to test
Private Sub test_getBaristaSalary()
Dim InputYear As Integer
InputYear = InputBox(Prompt:="How many years of Experience?")
MsgBox Prompt:="Total Salary is $" & getBaristaSalary(Whatyearisit:=InputYear)
End Sub
Function getBaristaSalary(Whatyearisit As Integer)
getBaristaSalary = Whatyearisit * 500 + 18000
' Annual Salary = $18000 + $500x(years as barista)
End Function
Function 2 is
Private Sub test_getManagerSalary()
Dim InputYearBarista As Integer
Dim InputYearManager As Integer
InputYearBarista = InputBox(Prompt:="Years of experience as Barista?")
InputYearManager = InputBox(Prompt:="Years of experience as Manager?")
MsgBox Prompt:="Total Salary is $" & getManagerSalary(BaristaYear:=InputYearBarista, ManagerYear:=InputYearManager)
End Sub
Function getManagerSalary(BaristaYear As Integer, ManagerYear As Integer)
getManagerSalary = (BaristaYear * 500) + (ManagerYear * 1000) + 22000
' Annual Salary = $22000 + $500x(years as barista) + $1000x(years as a manager)
End Function
My third function needs to determine which of the first 2 functions will be used to calculate the equation based on the answer to InputYearManager. If the value of InputYearManager is anything besides 0 then I need to use the second function however if 0 is the answer then I need the first function used.
So far I have this:
[B]
Private Sub test_getPredictedSalary()
Dim InputYearBarista As Integer
Dim InputYearManager As Integer
InputYearManager = InputBox(Prompt:="Years of experience as Manager?")
InputYearBarista = InputBox(Prompt:="Years of experience as Barista?")
MsgBox Prompt:="Total Salary is $" & getPredictedSalary(BaristaYear:=InputYearBarista, ManagerYear:=InputYearManager)
End Sub
Function getPredictedSalary(BaristaYear As Integer, ManagerYear As Integer) As Double
If InputYearManager >= 0 Then
getPredictedSalary = getManagerSalary
ElseIf InputYearManager = 0 Then
getPredictedSalary = getBaristaSalary
End If
End Function
' Annual Salary = $22000 + $500x(years as barista) + $1000x(years as a manager)
' Annual Salary = $18000 + $500x(years as barista)
When I run this I get a Complie Error: Argument not optional. Any suggestions?
Bookmarks