VB计算BMI指数

VB计算BMI指数,第1张

你的公式不对a/(b*2),我帮你改成a/(b*1.6),看起来差不多,实际公式拿基是桥侍a=b-1.05是标准身材。 Private Sub Command1_Click()

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

BMI是用拆昌体重公斤数除以身高米数平方得旅携扒出的数字

体质指数(BMI)=体重(kg)÷身高^2(m)

a=val(inputbox("输入隐祥体重"))

b=val(inputbox("输入身高"))

bmi=a/ b^2

msgbox bmi

就四句代码很简单的


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12289067.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存