WindsorKnot
Board Regular
- Joined
- Jan 4, 2009
- Messages
- 160
Hi,
I'm trying to learn how to write functions with Select Case and am having trouble with my code below. Basically, it returns 0 when any of the three plans below are selected. Basically there if for example Health - Option 1 is selected I want the function to return "High". I know how to do this using the if-then arguements but want to learn how to do this using select case. Any input would greatly appreciated.
I'm trying to learn how to write functions with Select Case and am having trouble with my code below. Basically, it returns 0 when any of the three plans below are selected. Basically there if for example Health - Option 1 is selected I want the function to return "High". I know how to do this using the if-then arguements but want to learn how to do this using select case. Any input would greatly appreciated.
Code:
Function plan(tier)
Dim High As String
Dim Mid As String
Dim Low As String
Dim Opt1 As String
Dim Opt2 As String
Dim Opt3 As String
Opt1 = "Health - Option 1"
Opt2 = "HDHP Lower Deductible"
Opt3 = "HDHP High Deductible"
Select Case tier
Case Opt1
plan = High
Case Opt2
plan = Mid
Case Opt3
plan = Low
Case Else
MsgBox "Select a valid plan"
Exit Function
End Select
End Function