R RAJAN MBA Member Licensed User Longtime User Jun 26, 2014 #1 What's wrong with this code? MMI is a double .The compiler suggest: ',' expected in select. Code: Copy Select MMI Case 0.0 To 2.0 dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions" Case 2.1 To 2.9 dist_txt=........ changing Case 0.0 To 2.0 Click to expand... to Case 0.0, 2.0 Click to expand... shows 'Missing Parameter' error Last edited: Jun 26, 2014
What's wrong with this code? MMI is a double .The compiler suggest: ',' expected in select. Code: Copy Select MMI Case 0.0 To 2.0 dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions" Case 2.1 To 2.9 dist_txt=........ changing Case 0.0 To 2.0 Click to expand... to Case 0.0, 2.0 Click to expand... shows 'Missing Parameter' error
stevel05 Expert Licensed User Longtime User Jun 26, 2014 #2 You can't use 'To' in a Case statement, you would have to state each value separated by a ",": Code: Copy Select MMI Case 0.0, 0.1,0.2,0.3 'etc dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions" End Select It would be easier using If statements for this example. Code: Copy If MMI >= 0.00 Then If MMI <= 2.0 Then dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions" Else If MMI <= 2.9 Then dist_txt=........ Else If MMI <= 3.9 Then 'etc End if End If End if End if Upvote 0
You can't use 'To' in a Case statement, you would have to state each value separated by a ",": Code: Copy Select MMI Case 0.0, 0.1,0.2,0.3 'etc dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions" End Select It would be easier using If statements for this example. Code: Copy If MMI >= 0.00 Then If MMI <= 2.0 Then dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions" Else If MMI <= 2.9 Then dist_txt=........ Else If MMI <= 3.9 Then 'etc End if End If End if End if
R RAJAN MBA Member Licensed User Longtime User Jun 26, 2014 #3 Thanks stevel05. I have been using 'to' in select case statements in VB etc. so I thought it will work. I will go by 'If Else' since 'Case 0.0,1.0,2.0' throws up missing parameter error (I have to see if it is unrelated to Case statement) Upvote 0
Thanks stevel05. I have been using 'to' in select case statements in VB etc. so I thought it will work. I will go by 'If Else' since 'Case 0.0,1.0,2.0' throws up missing parameter error (I have to see if it is unrelated to Case statement)
NJDude Expert Licensed User Longtime User Jun 26, 2014 #4 You can try something like this: Code: Copy Dim Var As Int Var = 1 Select True Case (Var >= 0 AND Var <= 2) Msgbox("Between zero and 2", "") Case (Var >= 2 AND Var <= 4) Msgbox("Between 2 and 4", "") End Select Upvote 0
You can try something like this: Code: Copy Dim Var As Int Var = 1 Select True Case (Var >= 0 AND Var <= 2) Msgbox("Between zero and 2", "") Case (Var >= 2 AND Var <= 4) Msgbox("Between 2 and 4", "") End Select
LucaMs Expert Licensed User Longtime User Jun 26, 2014 #7 NJDude said: You can try something like this: Code: Copy Dim Var As Int Var = 1 Select True Case (Var >= 0 AND Var <= 2) Msgbox("Between zero and 2", "") Case (Var >= 2 AND Var <= 4) Msgbox("Between 2 and 4", "") End Select Click to expand... Var should be a Float or a Double Upvote 0
NJDude said: You can try something like this: Code: Copy Dim Var As Int Var = 1 Select True Case (Var >= 0 AND Var <= 2) Msgbox("Between zero and 2", "") Case (Var >= 2 AND Var <= 4) Msgbox("Between 2 and 4", "") End Select Click to expand... Var should be a Float or a Double
R RAJAN MBA Member Licensed User Longtime User Jun 27, 2014 #8 Ha, Select True ! It's a savior. I too forgot about it Thanks all Upvote 0