求大神帮忙,用VB设计程序,有两个题目

2025-03-02 11:23:27
推荐回答(1个)
回答1:

Option Explicit

Private Sub Form_Load()
    Dim a, b, c
getold:
    a = InputBox("您的年龄是多少岁?(不输入视为退出)")
    If a = "" Then End
    If IsNumeric(a) = False Then
        MsgBox "请输入一个数字!"
        GoTo getold
    End If
getheavy:
    b = InputBox("您的体重是多少千克?(不输入视为退出)")
    If b = "" Then End
    If IsNumeric(b) = False Then
        MsgBox "请输入一个数字!"
        GoTo getheavy
    End If
startget:
    Select Case a
        Case 1 To 3
            c = 1.8 * b
        Case 4 To 6
            c = 1.49 * b
        Case 7 To 10
            c = 1.21 * b
        Case 11 To 14
            c = 0.99 * b
        Case 15 To 18
            c = 0.88 * b
        Case Is >= 19
            c = 0.79 * b
        Case Else
            MsgBox "无效的年龄!"
            End
    End Select
    MsgBox "您一天所需的蛋白质:" & c & "克"
    End
End Sub

希望楼主能够采纳我,谢谢。

所需蛋白质量计算公式:http://zhidao.baidu.com/link?url=1bzgxDDWWYdSB2i0AnkDAy2cdFAO_ui9FdNDBI6niYcWJcpbIeDeNzrasp4t-vbG6R0rpnsbdqdIuegcYdNJe_