Guest_imported
New member
- Jan 1, 1970
- 0
Keep getting an overflow error from this code. something to do with the result variable. can anyone help???
Private Sub Command2_Click()
Dim height, weight, result As Integer
weight = Val(Text2.Text)
height = Val(Text1.Text)
result = weight / ((height) ^ 2)
Select Case result
Case Is < 17
text3.Text = "Your BMI is " & result & " which indicates that you are grossly undernourished."
Case "17" To "19"
text3.Text = "Your BMI is " & result & " which indicates that you are undernourished"
Case "20" To "25"
text3.Text = "Your BMI is " & result & " which indicates that you have a perfectly good weight for your height"
Case "26" To "29"
text3.Text = "Your BMI is " & result & " which indicates that you are fat"
Case "30" To "39"
text3.Text = "Your BMI is " & result & " which indicates that you are obese"
Case Is > 39
text3.Text = "Your BMI is " & result & " which indicates that you are very obese"
Case "A" To "Z", "a" To "z"
MsgBox "You must only enter numeric values"
End Select
End Sub
Private Sub Command2_Click()
Dim height, weight, result As Integer
weight = Val(Text2.Text)
height = Val(Text1.Text)
result = weight / ((height) ^ 2)
Select Case result
Case Is < 17
text3.Text = "Your BMI is " & result & " which indicates that you are grossly undernourished."
Case "17" To "19"
text3.Text = "Your BMI is " & result & " which indicates that you are undernourished"
Case "20" To "25"
text3.Text = "Your BMI is " & result & " which indicates that you have a perfectly good weight for your height"
Case "26" To "29"
text3.Text = "Your BMI is " & result & " which indicates that you are fat"
Case "30" To "39"
text3.Text = "Your BMI is " & result & " which indicates that you are obese"
Case Is > 39
text3.Text = "Your BMI is " & result & " which indicates that you are very obese"
Case "A" To "Z", "a" To "z"
MsgBox "You must only enter numeric values"
End Select
End Sub