question about spaces in name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone tell me why the code below won't work for me? It's not picking up
the results from the "OTHER" sections of "General Developmental" and "LAB
TEST RESULTS". Because the OTHER section worked for "Musculoskeletal", I
have a feeling this is a result of the values for that column (General
Developmental, and LAB TEST RESULTS) have spaces in them. Can anyone help me
get around this without having to change all the values in the SQL database?

'Musculoskeletal Symptoms
Case "Scoliosis"
If Not dr("CHOICE").ToString = "NA" Then
lblMS_S.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblMS_S_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "Achilles Tendon Contractures"
If Not dr("CHOICE").ToString = "NA" Then
lblMS_ATC.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblMS_ATC_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "Knee Contractures"
If Not dr("CHOICE").ToString = "NA" Then
lblMS_KC.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblMS_KC_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "ELBOW Contractures"
If Not dr("CHOICE").ToString = "NA" Then
lblMS_EC.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblMS_EC_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
Case "NECK Contractures"
If Not dr("CHOICE").ToString = "NA" Then
lblMS_NC.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA" Then
lblMS_NC_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If

****HERE IT WORKS!***
Case "OTHER"
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

****HERE IT DOES NOT WORK!!!********
Case "OTHER"
If dr("MAIN_CATEGORY").ToString = "General
Developmental" 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
'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

****HERE IT DOES NOT WORK!!!*****
Case "OTHER"
If dr("MAIN_CATEGORY").ToString = "LAB TEST RESULTS"
Then
If Not dr("CHOICE").ToString = "NA" Then
lblLTR_O.Text = dr("CHOICE").ToString.ToUpper
End If
If Not dr("IS_FAMILY_HISTORY").ToString = "NA"
Then
lblLTR_O_F.Text =
dr("IS_FAMILY_HISTORY").ToString.ToUpper
End If
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

End Select

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
Catch err As SqlException
Dim sqlerr As String = err.Message
End Try
tblSymptoms.Visible = True
lkbSymDown.Visible = True
lkbSymUp.Visible = False

End Sub
 
ST said:
Can anyone tell me why the code below won't work for me? It's not picking up
the results from the "OTHER" sections of "General Developmental" and "LAB
TEST RESULTS". Because the OTHER section worked for "Musculoskeletal", I
have a feeling this is a result of the values for that column (General
Developmental, and LAB TEST RESULTS) have spaces in them. Can anyone help me
get around this without having to change all the values in the SQL database?

Well, have you checked what the value of dr("MAIN_CATEGORY") actually
is at runtime? Maybe the string is being truncated, or something like
that.
 
hmm that seems to be OK. it looks like it's not recognizing the "OTHER"
cases. It skips right over them...but recognizes it in the Musculoskeletal
group.
 
ST said:
hmm that seems to be OK. it looks like it's not recognizing the "OTHER"
cases. It skips right over them...but recognizes it in the Musculoskeletal
group.

When you step through in the debugger, which line is it getting to
before skipping where you don't expect it to?
 
Ok, I've debugged line by line....this is what it looks like:
-For General developmental, it doesn't seem to even be recognizing the OTHER
case...it skips right over it and goes from CASE Behavioral Problems, right
to the notes.
-For LAB TEST RESULTS, it recognizes the CASE OTHER, BUT, it seems to be
going thru the code below the CASE OTHER in the Musculoskeletal section,
which the first If statement for dr("MAIN CATEGORY") always results in false
because it's the wrong section. When I do a watch window The MAIN CATEGORY
is LAB TEST RESULTS...however it just seems to be running thru this code for
some reason:
Case "OTHER"
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

***Instead of this code:
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


What do you think might be going on?? I'm sort of new to vb.net...and I'm
trying to work with code that someone else wrote. There is something else I
don't understand. It seems to also be going thru an EMG section which I
can't find anywhere in the code. When I debug, the main category changes to
EMG, but there are no EMG cases anywhere...but it seems to run thru it. Do
you think there's some hidden code somewhere? Thanks for your help!
 
ST said:
Ok, I've debugged line by line....this is what it looks like:
-For General developmental, it doesn't seem to even be recognizing the OTHER
case...it skips right over it and goes from CASE Behavioral Problems, right
to the notes.

Have you checked the length of the string in the debugger, to see if
it's got any trailing spaces or anything like that?
-For LAB TEST RESULTS, it recognizes the CASE OTHER, BUT, it seems to be
going thru the code below the CASE OTHER in the Musculoskeletal section,
which the first If statement for dr("MAIN CATEGORY") always results in false
because it's the wrong section. When I do a watch window The MAIN CATEGORY
is LAB TEST RESULTS...however it just seems to be running thru this code for
some reason:
Case "OTHER"
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

***Instead of this code:
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


What do you think might be going on?? I'm sort of new to vb.net...and I'm
trying to work with code that someone else wrote. There is something else I
don't understand. It seems to also be going thru an EMG section which I
can't find anywhere in the code. When I debug, the main category changes to
EMG, but there are no EMG cases anywhere...but it seems to run thru it. Do
you think there's some hidden code somewhere? Thanks for your help!

I wonder whether the debugger is out of date with the code that you've
got in front of you. I've seen that a few times - cleaning out the
whole project and rebuilding usually fixes it for me.
 
Well I just checked the length of the string...it says it's 5 for "OTHER" so
that seems to make sense. What do you mean exactly when you say "clean out"
and rebuild? That might work.
 
ST said:
Well I just checked the length of the string...it says it's 5 for "OTHER" so
that seems to make sense. What do you mean exactly when you say "clean out"
and rebuild? That might work.

I mean you should shut down VS.NET, find the binaries and any
intermediate files (in the bin and obj directories for C# - I don't
know about VB.NET) and delete them. Then restart, rebuild, and see if
that helps.
 
ok I just tried that. Didn't seem to work. Any other suggestions? I just
can't see what could be wrong with this. Is there anything else I should
look for in particular when I debug?
 
ST said:
ok I just tried that. Didn't seem to work. Any other suggestions? I just
can't see what could be wrong with this. Is there anything else I should
look for in particular when I debug?

None that I can think of. I suggest you start a new project which
*just* has this bit of code in (and whatever you need to get the sample
data) - that may make it easier to debug. If you find that the same
code is doing different things in one project than in another, you know
there's something very odd going on...
 
Back
Top