By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

syntax for Select Case statements

P: n/a
ST
Hi, I'm trying to debug someone else's code, and I'm going thru this Select
Case statement. I'm having problems with the "OTHER" case...in that when the
first line of the case is false, it jumps to the end of the select case
block, instead of finishing going thru the rest of the cases (and thereby
reaching the next "OTHER" case). Can anyone explain this to me?? Thanks!
I've put ***** where things seems to mess up!

Select Case dr("SUBCATEGORY").ToString
Case "Developmental Delay"
If Not dr("CHOICE").ToString = "NA" Then
lblNS_DD.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblNS_DD_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "Hypotonia"
If Not dr("CHOICE").ToString = "NA" Then
lblNS_H.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblNS_H_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
******Case "OTHER" (if this is false, it goes to the very end of this whole
block!)
If dr("MAIN_CATEGORY") = "Musculoskeletal" Then
If Not dr("CHOICE").ToString = "NA" Then
lblMS_O.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA"
Then
lblMS_O_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
End If
'General Developmental
Case "Language Delay"
If Not dr("CHOICE").ToString = "NA" Then
lblGD_LA.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblGD_LA_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "Learning Disability"
If Not dr("CHOICE").ToString = "NA" Then
lblGD_LE.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblGD_LE_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "ADHD/ADD"
If Not dr("CHOICE").ToString = "NA" Then
lblGD_AD.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblGD_AD_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "Behavioral Problems"
If Not dr("CHOICE").ToString = "NA" Then
lblGD_BP.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblGD_BP_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
******** Case "OTHER" (passes over this Case and all those above/below)
If dr("MAIN_CATEGORY") = "General Developmental" Then
If Not dr("CHOICE").ToString = "NA" Then
lblGD_O.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA"
Then
lblGD_O_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
End If
'Lab Test Results
Case "Elevated Transaminases"
If Not dr("CHOICE").ToString = "NA" Then
lblLTR_ET.Text = dr("CHOICE")
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblLTR_ET_F.Text = dr("IS_FAMILY_HISTORY")
End If
Case "Aldolase"
If Not dr("CHOICE").ToString = "NA" Then
lblLTR_A.Text = dr("CHOICE")
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblLTR_A_F.Text = dr("IS_FAMILY_HISTORY")
End If
Case "MAX CPK 1ST VALUE"
If Not dr("CHOICE").ToString = "NA" Then
lblLTR_CPK1.Text = dr("CHOICE")
End If
Case "MAX CPK 2ND VALUE"
If Not dr("CHOICE").ToString = "NA" Then
lblLTR_CPK2.Text = dr("CHOICE")
End If
Case "OTHER"
If dr("MAIN_CATEGORY") = "LAB TEST RESULTS" Then
If Not dr("CHOICE").ToString = "NA" Then
lblLTR_O.Text = dr("CHOICE")
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA"
Then
lblLTR_O_F.Text = dr("IS_FAMILY_HISTORY")
End If
End If
***** End Select (it goes here and continues on below)

If dr("VALUE_ID").ToString = "CVID-502" Then
If dr("CLINICAL_VALUE_OTHER_NOTE").ToString = "" Then
lblVS_O_Text.Text = ""
Else
lblVS_O_Text.Text =
dr("CLINICAL_VALUE_OTHER_NOTE").ToString
End If
End If
If dr("VALUE_ID").ToString = "CVID-500" Then
If dr("CLINICAL_VALUE_OTHER_NOTE").ToString = "" Then
lblMS_O_Text.Text = ""
Else
lblMS_O_Text.Text =
dr("CLINICAL_VALUE_OTHER_NOTE").ToString
End If
End If
If dr("VALUE_ID").ToString = "CVID-504" Then
If dr("CLINICAL_VALUE_OTHER_NOTE").ToString = "" Then
lblGD_O_Text.Text = ""
Else
lblGD_O_Text.Text =
dr("CLINICAL_VALUE_OTHER_NOTE").ToString
End If
End If
If dr("VALUE_ID").ToString = "CVID-506" Then
If dr("CLINICAL_VALUE_OTHER_NOTE").ToString = "" Then
lblLTR_O_Text.Text = ""
Else
lblLTR_O_Text.Text =
dr("CLINICAL_VALUE_OTHER_NOTE").ToString
End If
End If
Next
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


ST wrote:
first line of the case is false, it jumps to the end of the select case
block, instead of finishing going thru the rest of the cases (and thereby
reaching the next "OTHER" case). Can anyone explain this to me?? Thanks!
I've put ***** where things seems to mess up!


Are you saying that it executes the first block marked "OTHER" and then
skips every thing else? I think that behavior is by design,

Looking at the IL for a select case, it appears that at the end of each
block it puts a jump to the end of the select case. In effect, once it
enters a case block, it doesn't even check the other conditions
anymore.

Probably the simplest solution is to just combine the code from both
"OTHER" blocks. This would be more readable anyway.

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.