Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overflows

Status
Not open for further replies.

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 = &quot;Your BMI is &quot; & result & &quot; which indicates that you are grossly undernourished.&quot;
Case &quot;17&quot; To &quot;19&quot;
text3.Text = &quot;Your BMI is &quot; & result & &quot; which indicates that you are undernourished&quot;
Case &quot;20&quot; To &quot;25&quot;
text3.Text = &quot;Your BMI is &quot; & result & &quot; which indicates that you have a perfectly good weight for your height&quot;
Case &quot;26&quot; To &quot;29&quot;
text3.Text = &quot;Your BMI is &quot; & result & &quot; which indicates that you are fat&quot;
Case &quot;30&quot; To &quot;39&quot;
text3.Text = &quot;Your BMI is &quot; & result & &quot; which indicates that you are obese&quot;
Case Is > 39
text3.Text = &quot;Your BMI is &quot; & result & &quot; which indicates that you are very obese&quot;
Case &quot;A&quot; To &quot;Z&quot;, &quot;a&quot; To &quot;z&quot;
MsgBox &quot;You must only enter numeric values&quot;

End Select

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top