BMI指数 |
<18.522.9 |
18.5~23~ |
25~24.9 |
29.9 |
≥30 |
≥40.0 |
结果 |
偏瘦 |
正常 |
偏胖 |
肥胖 |
重度肥胖 |
极重度肥胖 |
程序运行时,在文本框Text1中输入体重,在文本框Text2中输入身高,单击”测试”按钮Command1,在标签Label4中显示对应的结果。程序运行界面如下图所示。
实现上述功能的VB程序如下,请回答下列问题:
Private Sub Command1_Click()
Dim h As Single, w As Single, ans As Single, s As String
w = Val(Text1.Text)
h = Val(Text2.Text)
①
If ans< 18.5 Then
s = “偏瘦”
ElseIf ans< 22.9 Then
s = “正常”
ElseIf ans<= 24.9 Then
s = “偏胖”
ElseIf ans<= 29.9 Then
s = “肥胖”
ElseIf ans< 40 Then
s = “重度肥胖”
②
s = “极重度肥胖”
End If
Label4.Caption = s
End Sub
① ②