体脂肪率计算软件说明书
一、设计背景
肥胖症是现代社会威胁人类健康的主要杀手,衡量肥胖症的指标之一是体脂肪率,它是将脂肪含量用其占总体重的百分比的形式表示。体脂肪率计算公式为:
其中男性性别取值为1,女性取值为0。一般认为男性体脂>25%,女性>33%是诊断肥胖的标准。
试设计一个VBA窗体程序,计算体脂肪率。
要求输出时,给出性别和合理的体脂肪率。
将该软件开发成APP,应用于平常手机中可以有效帮助肥胖或潜在肥胖人群监控自身体重,随时随地督促自己进行食量控制和健康锻炼。在社会中可以掀起锻炼的风潮,有助于全民健康。
二、面向对象程序说明
(一)构造界面控件说明
窗体对象界面元素对象实例说明对象所属的类对象事件窗体Form 窗体Load
文字“欢迎使用体脂肪率计算软件”Label192 标签
文字“身高”Label492 标签
“身高”后文本框Height92 文本框
文字“米”Label792 标签
文字“体重”Label692 标签
(二)控件属性说明
(三)控件事件代码说明
(四)程序代码
Option Compare Database
Private Sub form_load()
Me.Caption = "欢迎使用计算体脂肪率软件"
Me.age92.Value = ""
Me.height92.Value = ""
Me.weight92.Value = ""
Me.rate92.Value = ""
Me.opt_female92.Value = False
Me.opt_male92.Value = False
End Sub
Private Sub opt_male92_click()
If opt_male92.Value = True Then
opt_female92.Value = False
End If
End Sub
Private Sub opt_female92_click()
If opt_female92.Value = True Then
opt_male92.Value = False
End If
End Sub
Private Sub cmd_rate92_click()
Dim age, sex As Integer
Dim weight, height, rate As Double
If Me.opt_male92.Value Then
sex = 1
ElseIf Me.opt_female92.Value Then
sex = 0
End If
age = Me.age92.Value
height = Me.height92.Value
weight = Me.weight92.Value
rate = 1.2 * weight / (height ^ 2) + 0.23 * age - 5.4 - 10.8 * sex rate92.Value = rate
'给男性的建议
If sex = 1 And rate >= 10 And rate <= 25 Then
MsgBox ("帅哥,您的体型正常")
ElseIf sex = 1 And rate < 10 Then
MsgBox ("帅哥,您的体型偏瘦")
ElseIf sex = 1 And rate > 25 Then
MsgBox ("帅哥,您的体型过胖,食量适度= =") End If
'给女性的建议
If sex = 0 And rate >= 15 And rate <= 33 Then
MsgBox ("女士,您的体型正常")
ElseIf sex = 0 And rate < 15 Then
MsgBox ("女士,您需要加强营养哦")
ElseIf sex = 0 And rate > 33 Then
MsgBox ("女士,少吃有助于身心健康~")
End If
End Sub
Private Sub cmd_again92_click()
Me.age92.Value = ""
Me.height92.Value = ""
Me.weight92.Value = ""
Me.rate92.Value = ""
Me.opt_female92.Value = False
Me.opt_male92.Value = False
End Sub
三、体脂肪率计算数据测试的截图说明
图一:---输入数据---
图二—得出结果,弹出建议框---
图三--再来一次,清空数据--