'因为<0 与<=10的结果是一样的 所以并起
Select Case X
Case Is <= 10
y = X
Case 10 To 20
y = 10
Case 20 To 40
y = -0.5 * X + 20
End Select
'不嵌套
If X < 10 Then
y = X
ElseIf X > 10 And X <= 20 Then
y = 10
ElseIf X > 20 And a <= 40 Then
y = -0.5 * X + 20
End If
'嵌套
If X <= 20 Then
If X <= 10 Then y = X Else y = 10
ElseIf X > 20 And X <= 40 Then
y = -0.5 * X + 20
End If