我试图使所有Code 3员工和所有在公司工作5年的员工获得5%的加薪,而拥有其他工作代码或的员工在公司任职不到5年的员工可获得4.5%的加薪。我似乎已经有了Code 3,并且已经在公司工作了5年的员工才能正常运行,但是,我仍然坚持如何编写“所有其他工作代码”并从中排除工作Code 3。下面是我的代码:
'declare variables
Dim intCode As Integer
Dim strYears As String
Dim intYears As Integer
Dim sngRaise As Single
'enter employee code and years employed
intCode = InputBox(prompt:="Enter the employee
code: ", Title:="Code")
strYears = InputBox(prompt:="Enter the number of
years employed: ", _
Title:="Years")
'convert years to a number
intYears = Val(strYears)
'assign raise rate
Select Case True
Case intCode = "3" Or strYears >= 5
sngRaise = 0.05
Case intCode = 1 To 2 Or strYears <= 5
sngRaise = 0.045
End Select
MsgBox prompt:=Format(expression:=sngRaise,
Format:="percent"), _
Buttons:=vbOKOnly + vbInformation, Title:="Raise
Rate"