Click to See Complete Forum and Search --> : if else statement


leeny
01-31-2005, 08:35 PM
can anyone tell me is there anything worng with my if else statement? cause it's not working well. thanks


If age < 50 Then
CPFE = 0.2
CPFR = 0.13
ElseIf 49 < age < 55 Then
CPFE = 0.2
CPFR = 0.11
ElseIf 54 < age < 60 Then
CPFE = 0.125
CPFR = 0.06
ElseIf 59 < age < 65 Then
CPFE = 0.075
CPFR = 0.035
Else'If age > 64 then
CPFE = 0.005
CPFR = 0.035
End If

russell
01-31-2005, 08:53 PM
2 ways come to mind:

If age < 50 Then
CPFE = 0.2
CPFR = 0.13
ElseIf (age < 55) and (age > 49) Then
CPFE = 0.2
CPFR = 0.11
ElseIf (age < 60) and (age > 54) Then
CPFE = 0.125
CPFR = 0.06
ElseIf (age < 65) and (age > 59) Then
CPFE = 0.075
CPFR = 0.035
Else
CPFE = 0.005
CPFR = 0.035
End If

'' OR You could do this

Select Case True
Case age < 50
CPFE = 0.2
CPFR = 0.13
Case age > 49
CPFE = 0.2
CPFR = 0.11
Case age > 54
CPFE = 0.125
CPFR = 0.06
Case age > 59
CPFE = 0.075
CPFR = 0.035
Case age > 64
CPFE = 0.005
CPFR = 0.035
End Select