Dear all,
I am developing an app that medical students can use for reviewing simulated patient’s lab test results. I have a menu with three cases: SVT, CHF and PE.
For each case, students check checkboxes with the tests they want to see, click BtnOrder pushbutton, and the text area is populated with test results. If a parameter’s value is out of normal range, it is presented in red font. All seems to be simple and straightforward. When I try to compile the code below I am getting the following errors
Window1.BtnOrder.Pressed, line 214 - Syntax error End Sub
Window1.Name - Syntax error Window 1
Removing Sub BtnOrder_Pressed() and End Sub produces dozens of error.
I’ve checked the names of UI elements (checkboxes), buttons, text field - all are properly named.
Can someone tell me what I am doing wrong?
Sub BtnOrder_Pressed()
// Assume NormalRanges is a global Dictionary loaded at app startup
// It maps test names to Dictionaries with keys: "Low", "High", "Unit"
// Example: NormalRanges.Value("Na") = Dictionary with Low=135.0, High=145.0, Unit="mmol/L"
Var labs As New Dictionary
// Select labs based on CurrentCase (global variable)
Select Case CurrentCase
Case "P1 CV - SVT"
labs.Value("Na") = 140
labs.Value("K") = 4.2
labs.Value("Cl") = 102
labs.Value("CO2") = 24
labs.Value("BUN") = 15
labs.Value("Creatinine") = 1.0
labs.Value("Glucose") = 90
labs.Value("Ca") = 9.5
labs.Value("Mg") = 2.0
labs.Value("WBC") = 8.0
labs.Value("Hgb") = 14.0
labs.Value("Hct") = 42.0
labs.Value("Platelets") = 250
labs.Value("Neutrophils") = 58.0
labs.Value("Lymphocytes") = 32.0
labs.Value("Monocytes") = 6.0
labs.Value("Eosinophils") = 2.0
labs.Value("Basophils") = 0.5
labs.Value("Troponin") = 0.02
labs.Value("CKMB") = 2.0
labs.Value("BNP") = 50
labs.Value("pH") = 7.40
labs.Value("pCO2") = 40
labs.Value("pO2") = 95
labs.Value("HCO3") = 24
labs.Value("SaO2") = 98
labs.Value("D-Dimer") = 0.2
labs.Value("PT") = 12.5
labs.Value("INR") = 1.0
labs.Value("aPTT") = 30
labs.Value("ALT") = 30
labs.Value("AST") = 25
labs.Value("ALP") = 90
labs.Value("BilirubinTotal") = 0.8
labs.Value("Albumin") = 4.0
labs.Value("ThyroidStimHormone") = 2.0
labs.Value("HIV") = 0 // Negative
labs.Value("Pregnancy") = 0 // Negative
labs.Value("Urinalysis") = 0
labs.Value("BloodCultures") = 0
labs.Value("UrineCultures") = 0
labs.Value("UrineTox") = 0
labs.Value("HepatitisPanel") = 0
labs.Value("LacticAcid") = 1.0
Case "P1 RUS - CHF_PE"
labs.Value("Na") = 131
labs.Value("K") = 5.4
labs.Value("Cl") = 96
labs.Value("CO2") = 20
labs.Value("BUN") = 28
labs.Value("Creatinine") = 1.6
labs.Value("Glucose") = 110
labs.Value("Ca") = 8.3
labs.Value("Mg") = 1.8
labs.Value("WBC") = 9.0
labs.Value("Hgb") = 13.5
labs.Value("Hct") = 40
labs.Value("Platelets") = 240
labs.Value("Neutrophils") = 65.0
labs.Value("Lymphocytes") = 25.0
labs.Value("Monocytes") = 7.0
labs.Value("Eosinophils") = 2.5
labs.Value("Basophils") = 0.5
labs.Value("Troponin") = 0.08
labs.Value("CKMB") = 6.0
labs.Value("BNP") = 1200
labs.Value("pH") = 7.28
labs.Value("pCO2") = 52
labs.Value("pO2") = 60
labs.Value("HCO3") = 20
labs.Value("SaO2") = 88
labs.Value("D-Dimer") = 0.3
labs.Value("PT") = 13.0
labs.Value("INR") = 1.1
labs.Value("aPTT") = 31
labs.Value("ALT") = 55
labs.Value("AST") = 40
labs.Value("ALP") = 140
labs.Value("BilirubinTotal") = 1.1
labs.Value("Albumin") = 3.5
labs.Value("ThyroidStimHormone") = 2.5
labs.Value("HIV") = 0 // Negative
labs.Value("Pregnancy") = 0 // Negative
labs.Value("Urinalysis") = 0
labs.Value("BloodCultures") = 0
labs.Value("UrineCultures") = 0
labs.Value("UrineTox") = 0
labs.Value("HepatitisPanel") = 0
labs.Value("LacticAcid") = 2.0
Case "P1 PULM - PE"
labs.Value("Na") = 138
labs.Value("K") = 4.0
labs.Value("Cl") = 102
labs.Value("CO2") = 22
labs.Value("BUN") = 18
labs.Value("Creatinine") = 1.0
labs.Value("Glucose") = 95
labs.Value("Ca") = 9.0
labs.Value("Mg") = 2.1
labs.Value("WBC") = 10.5
labs.Value("Hgb") = 14.2
labs.Value("Hct") = 43
labs.Value("Platelets") = 260
labs.Value("Neutrophils") = 62.0
labs.Value("Lymphocytes") = 30.0
labs.Value("Monocytes") = 5.0
labs.Value("Eosinophils") = 2.0
labs.Value("Basophils") = 1.0
labs.Value("Troponin") = 0.05
labs.Value("CKMB") = 3.0
labs.Value("BNP") = 150
labs.Value("pH") = 7.48
labs.Value("pCO2") = 30
labs.Value("pO2") = 68
labs.Value("HCO3") = 22
labs.Value("SaO2") = 92
labs.Value("D-Dimer") = 1.2
labs.Value("PT") = 12.0
labs.Value("INR") = 1.0
labs.Value("aPTT") = 29
labs.Value("ALT") = 28
labs.Value("AST") = 22
labs.Value("ALP") = 100
labs.Value("BilirubinTotal") = 0.9
labs.Value("Albumin") = 4.2
labs.Value("ThyroidStimHormone") = 1.8
labs.Value("HIV") = 0 // Negative
labs.Value("Pregnancy") = 0 // Negative
labs.Value("Urinalysis") = 0
labs.Value("BloodCultures") = 0
labs.Value("UrineCultures") = 0
labs.Value("UrineTox") = 0
labs.Value("HepatitisPanel") = 0
labs.Value("LacticAcid") = 1.1
Case Else
MessageBox("Unknown clinical case selected.")
Return
End Select
// Clear previous results
TextArea1.StyledText.Text = ""
// Display formatted results with color coding
For Each key As String In labs.Keys
Var val As Variant = labs.Value(key)
Var norm As Dictionary = NormalRanges.Value(key)
If norm = Nil Or (norm.Value("Low") = 0 And norm.Value("High") = 0) Then
// Non-numeric flags like HIV, Pregnancy etc.
Var displayText As String
Select Case key
Case "HIV", "Pregnancy", "BloodCultures", "UrineCultures", "UrineTox", "HepatitisPanel"
displayText = If(val = 0, "Negative", "Positive")
Case "Urinalysis"
displayText = If(val = 0, "Normal", "Abnormal")
Else
displayText = val.StringValue
End Select
Var line As String = key + " = " + displayText + EndOfLine + EndOfLine
TextArea1.StyledText.AppendText(line)
TextArea1.StyledText.TextColor(TextArea1.StyledText.Length - line.Length, line.Length) = &c000000 // black
Continue For
End If
// Numeric lab test with ranges
Var low As Double = norm.Value("Low")
Var high As Double = norm.Value("High")
Var unit As String = norm.Value("Unit")
Var line As String = key + " = " + val.StringValue + " " + unit + EndOfLine + _
"Normal range: " + low.ToString + " - " + high.ToString + " " + unit + EndOfLine + EndOfLine
TextArea1.StyledText.AppendText(line)
If val < low Or val > high Then
TextArea1.StyledText.TextColor(TextArea1.StyledText.Length - line.Length, line.Length) = &cFF0000 // red
Else
TextArea1.StyledText.TextColor(TextArea1.StyledText.Length - line.Length, line.Length) = &c000000 // black
End If
Next
End Sub