VB 程序书写题计算BMI 值 输出指数和结论

2025-03-29 09:53:59
推荐回答(1个)
回答1:

Dim a As Single, b As Single, c As Single
a = Val(Text1)
b = Val(Text2)
c = Round(a / (b * 1.6))
Label6.Caption = c
If Option1.Value Then
If c < 20 Then
Label8.Caption = "过轻"
ElseIf c < 25 Then
Label8.Caption = "适中"
ElseIf c < 30 Then
Label8.Caption = "过重"
ElseIf c < 35 Then
Label8.Caption = "肥胖"
ElseIf c >= 35 Then
Label8.Caption = "非常肥胖"
End If
Else
If c < 19 Then
Label8.Caption = "过轻"
ElseIf c < 24 Then
Label8.Caption = "适中"
ElseIf c < 29 Then
Label8.Caption = "过重"
ElseIf c < 34 Then
Label8.Caption = "肥胖"
ElseIf c >= 34 Then
Label8.Caption = "非常肥胖"
End If
End If
End Sub