急求!Visual Basic 2005的BMI(体重计算器)的程式编码!!! 谢谢谢谢你了!!!
发布网友
发布时间:2022-05-06 21:56
我来回答
共1个回答
热心网友
时间:2023-09-22 20:07
Public Class Form1
Dim result As BIM
Dim intWeight As Double
Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
Try
intWeight = (CInt(txtHeigh.Text) - 100)
Select Case Check(txtWeight.Text)
Case BIM.result
MsgBox("thin")
Case BIM.result1
MsgBox("fat")
Case BIM.result2
MsgBox("fit")
End Select
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Enum BIM As Integer
result = 0
result1 = 1
result2 = 2
End Enum
Function Check(ByVal weight As String) As BIM
If CDbl(weight) < (intWeight - 10) Then
Return BIM.result
ElseIf CDbl(weight) > (intWeight + 15) Then
Return BIM.result1
Else
Return BIM.result2
End If
End Function
End Class
这个列子对象只能用于成年人,因为儿童的BIM要涉及到规定的BIM格式(这个我还真不清楚)。如果要考虑全面的话,就要添加程序代码。O(∩_∩)O哈!时间有限,献丑了!