Problem with a "Select Case"
i wrote the following section below. when debugging开发者_如何学Go, i see that i enter the first Case okay. my problem is with the second Case - it does not enter it and goes to the error messege.
what do i do wrong?
Select Case Data_Rate
Case "1", "2", "5.5", "11", "6", "9", "12", "18", "24", "36", "48", "54"
a = Data_Rate
Select Case Date_Rate
Case "1"
b = 2
Case "2", "5.5", "11"
b = 1
Case Else:
MsgBox ("ERROR - Data_Rate")
End Select
Case "0", "1", "2", "3", "4", "5", "6", "7"
a = 3
Case Else:
MsgBox ("ERROR - Data_Rate")
End Select
Is that your actual code pasted in above?
If so, it may be because you have "datE_rate" instead of "datA_rate" as the value for your nested Select statement.
If not, or even if so, you may also want to differentiate your error messages so it's clearer whether it's the inner or outer Select that is failing.
Edit:
Also, I don't think you are using Option Explicit. If you were, it would have caught your mistaken use of Date_Rate, unless you actually do have such a variable.
For values like 1, 2, and 6 that are in both, it will always only execute the first case
I case statement is like a bunch of if/else if statements.
Only one block is executed
Not multiple blocks
精彩评论