S
Slightly Befuddled
I have a sizable select module for determining points based on a number of
criteria, I am not a programmer as will be evident by the code below. The
problem is only the first Select Case statement is properly evaluated, the
rest are assigned a zero value. I have verified that the variables used for
evaluation are correctly assigned and that they have good numbers. Any help
with this is greatly appreciated.
Private Sub Command20_Click()
Dim intAge As Integer
Dim strMessage As String
Dim intTC As Integer
Dim strSmoker As String
Dim intHdl As Integer
Dim intBP As Integer
Dim strBPmed As String
Dim intpoints As Integer
Dim intRisk As Integer
Dim intAgepoint As Integer
Dim intTcPoint As Integer
Dim intSmokerPoint As Integer
Dim intHdlPoint As Integer
Dim intBpPoint As Integer
intAge = Me.PtAge
intTC = Me.TC
strSmoker = Me.Smoker
intHdl = Me.HDL
intBP = Me.SBP
'evaluate patient age and assign score
Select Case intAge
Case 1 To 19
MsgBox "you are too young"
Case 20 To 34
intAgepoint = -9
Case 35 To 39
intAgepoint = -4
Case 40 To 44
intAgepoint = 0
Case 45 To 49
intAgepoint = 3
Case 50 To 54
intAgepoint = 6
Case 55 To 59
intAgepoint = 8
Case 60 To 64
intAgepoint = 10
Case 65 To 69
intAgepoint = 11
Case 70 To 74
intAgepoint = 12
Case 75 To 79
intAgepoint = 13
Case Else
MsgBox "you are outside the range of this measurement"
End Select
'evaluate Total Cholesterol level and assign points based on age
Select Case intTC
Case Is < 160
intTcPoint = 0
Case 160 To 199
Select Case intAge
Case 20 To 39
intTcPoint = 4
Case 40 To 49
intTcPoint = 3
Case 50 To 59
intTcPoint = 2
Case 60 To 69
intTcPoint = 1
Case 70 To 79
intTcPoint = 0
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case 200 To 239
Select Case intAge
Case 20 To 39
intTcPoint = 7
Case 40 To 49
intTcPoint = 5
Case 50 To 59
intTcPoint = 3
Case 60 To 69
intTcPoint = 1
Case 70 To 79
intTcPoint = 0
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case 240 To 279
Select Case intAge
Case 20 To 39
intTcPoint = 9
Case 40 To 49
intTcPoint = 6
Case 50 To 59
intTcPoint = 4
Case 60 To 69
intTcPoint = 2
Case 70 To 79
intTcPoint = 1
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case Is >= 280
Select Case intAge
Case 20 To 39
intTcPoint = 11
Case 40 To 49
intTcPoint = 8
Case 50 To 59
intTcPoint = 5
Case 60 To 69
intTcPoint = 3
Case 70 To 79
intTcPoint = 1
Case Else
MsgBox "you are outside the range of this measurement"
End Select
End Select
MsgBox "Your TCscore is " & intTcPoint & " your inttc is " & intTC
'Determine if patient is a smoker and assign points based on age
Select Case strSmoker
Case "yes"
Select Case intAge
Case 20 To 39
intSmokerPoint = 8
Case 40 To 49
intSmokerPoint = 5
Case 50 To 59
intSmokerPoint = 3
Case 60 To 69
intSmokerPoint = 1
Case 70 To 79
intSmokerPoint = 1
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case "no"
intSmokerPoint = 0
End Select
'assign points for HDL levels
Select Case intHdl
Case Is >= 60
intHdlPoint = -1
Case 50 To 59
intHdlPoint = 0
Case 40 To 49
intHdlPoint = 1
Case Is < 40
intHdlPoint = 2
End Select
'Assign points for treated and untreated Bloodpressure
Select Case intBP
Case Is < 120
intBpPoint = 0
Case 120 To 129
Select Case strBPmed
Case "yes"
intBpPoint = 1
Case "no"
intBpPoint = 0
End Select
Case 130 To 139
Select Case strBPmed
Case "yes"
intBpPoint = 2
Case "no"
intBpPoint = 1
End Select
Case 140 To 159
Select Case strBPmed
Case "yes"
intBpPoint = 2
Case "no"
intBpPoint = 1
End Select
Case Is >= 160
Select Case strBPmed
Case "yes"
intBpPoint = 3
Case "no"
intBpPoint = 2
End Select
End Select
'Quick box to tell separate point totals, to be replaced with sum function
MsgBox "your score is " & intpoints & intBpPoint & intHdlPoint &
intSmokerPoint
End Sub
criteria, I am not a programmer as will be evident by the code below. The
problem is only the first Select Case statement is properly evaluated, the
rest are assigned a zero value. I have verified that the variables used for
evaluation are correctly assigned and that they have good numbers. Any help
with this is greatly appreciated.
Private Sub Command20_Click()
Dim intAge As Integer
Dim strMessage As String
Dim intTC As Integer
Dim strSmoker As String
Dim intHdl As Integer
Dim intBP As Integer
Dim strBPmed As String
Dim intpoints As Integer
Dim intRisk As Integer
Dim intAgepoint As Integer
Dim intTcPoint As Integer
Dim intSmokerPoint As Integer
Dim intHdlPoint As Integer
Dim intBpPoint As Integer
intAge = Me.PtAge
intTC = Me.TC
strSmoker = Me.Smoker
intHdl = Me.HDL
intBP = Me.SBP
'evaluate patient age and assign score
Select Case intAge
Case 1 To 19
MsgBox "you are too young"
Case 20 To 34
intAgepoint = -9
Case 35 To 39
intAgepoint = -4
Case 40 To 44
intAgepoint = 0
Case 45 To 49
intAgepoint = 3
Case 50 To 54
intAgepoint = 6
Case 55 To 59
intAgepoint = 8
Case 60 To 64
intAgepoint = 10
Case 65 To 69
intAgepoint = 11
Case 70 To 74
intAgepoint = 12
Case 75 To 79
intAgepoint = 13
Case Else
MsgBox "you are outside the range of this measurement"
End Select
'evaluate Total Cholesterol level and assign points based on age
Select Case intTC
Case Is < 160
intTcPoint = 0
Case 160 To 199
Select Case intAge
Case 20 To 39
intTcPoint = 4
Case 40 To 49
intTcPoint = 3
Case 50 To 59
intTcPoint = 2
Case 60 To 69
intTcPoint = 1
Case 70 To 79
intTcPoint = 0
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case 200 To 239
Select Case intAge
Case 20 To 39
intTcPoint = 7
Case 40 To 49
intTcPoint = 5
Case 50 To 59
intTcPoint = 3
Case 60 To 69
intTcPoint = 1
Case 70 To 79
intTcPoint = 0
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case 240 To 279
Select Case intAge
Case 20 To 39
intTcPoint = 9
Case 40 To 49
intTcPoint = 6
Case 50 To 59
intTcPoint = 4
Case 60 To 69
intTcPoint = 2
Case 70 To 79
intTcPoint = 1
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case Is >= 280
Select Case intAge
Case 20 To 39
intTcPoint = 11
Case 40 To 49
intTcPoint = 8
Case 50 To 59
intTcPoint = 5
Case 60 To 69
intTcPoint = 3
Case 70 To 79
intTcPoint = 1
Case Else
MsgBox "you are outside the range of this measurement"
End Select
End Select
MsgBox "Your TCscore is " & intTcPoint & " your inttc is " & intTC
'Determine if patient is a smoker and assign points based on age
Select Case strSmoker
Case "yes"
Select Case intAge
Case 20 To 39
intSmokerPoint = 8
Case 40 To 49
intSmokerPoint = 5
Case 50 To 59
intSmokerPoint = 3
Case 60 To 69
intSmokerPoint = 1
Case 70 To 79
intSmokerPoint = 1
Case Else
MsgBox "you are outside the range of this measurement"
End Select
Case "no"
intSmokerPoint = 0
End Select
'assign points for HDL levels
Select Case intHdl
Case Is >= 60
intHdlPoint = -1
Case 50 To 59
intHdlPoint = 0
Case 40 To 49
intHdlPoint = 1
Case Is < 40
intHdlPoint = 2
End Select
'Assign points for treated and untreated Bloodpressure
Select Case intBP
Case Is < 120
intBpPoint = 0
Case 120 To 129
Select Case strBPmed
Case "yes"
intBpPoint = 1
Case "no"
intBpPoint = 0
End Select
Case 130 To 139
Select Case strBPmed
Case "yes"
intBpPoint = 2
Case "no"
intBpPoint = 1
End Select
Case 140 To 159
Select Case strBPmed
Case "yes"
intBpPoint = 2
Case "no"
intBpPoint = 1
End Select
Case Is >= 160
Select Case strBPmed
Case "yes"
intBpPoint = 3
Case "no"
intBpPoint = 2
End Select
End Select
'Quick box to tell separate point totals, to be replaced with sum function
MsgBox "your score is " & intpoints & intBpPoint & intHdlPoint &
intSmokerPoint
End Sub