Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27151

Calling functions

$
0
0
I posted this in the wrong area.. I really need some help with my first vb application.

It is a basal metabolic rate calculator

I got to say I am really new to vb and it will show...
Ok here goes..
Please be gentle its my first vb class and my first attempt with out directions.. Thanks everyone

Code:

Module Module1

    Public Const intWOMAN_AGE As Integer = 4.7
    Public Const intMEN_AGE As Integer = 6.8
    Public intInAge As Integer
    Public intInHeight As Integer
    Public intInWeight As Integer
    Public intTotaledBMR As Integer

    Public Function MensBMR(intTotaledBMR)
        Const intBMR_MEN As Integer = 66
        Const intMEN_WEIGHT As Integer = 6.23
        Const intMEN_HEIGHT As Integer = 12.7

        Return intTotaledBMR = intBMR_MEN + (intMEN_WEIGHT * intInWeight) + (intMEN_HEIGHT * intInHeight) - (intMEN_AGE * intInAge)
    End Function

    Public Function WomansBMR(intTotaledBMR)

        Const intBMR_WOMAN As Integer = 655
        Const intWOMAN_WEIGHT As Integer = 4.35
        Const intWOMEN_HEIGHT As Integer = 4.7

        Return intTotaledBMR = intBMR_WOMAN + (intWOMAN_WEIGHT * intInWeight) + (intWOMEN_HEIGHT * intInHeight) - (intWOMAN_AGE * intInAge)
    End Function
End Module

The main form is
Code:

Public Class frmBMR

 

    Private Sub btnBMRCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnBMRCalculate.Click

        Try
            intInAge = CInt(txtInAge.Text)
            intInHeight = CInt(txtInHeight.Text)
            intInWeight = CInt(txtInWeight.Text)

            If Integer.TryParse(txtInAge.Text, intInAge) Then


                If intInAge >= 10 And intInAge <= 100 Then
                    If intInHeight >= 48 And intInHeight <= 80 Then
                        If intInWeight >= 50 And intInWeight <= 300 Then

                        ElseIf radMale.Checked = True And
                                radStandard.Checked = True Then
                            lblTotaledBMR.Text = MensBMR(intTotaledBMR)

                        ElseIf radStandard.Checked = True And
                            radFemale.Checked = True Then
                            lbldisTotalBMR.Text = WomansBMR(intTotaledBMR)


                            MessageBox.Show("Select a Sex")
                        End If
                    MessageBox.Show("Enter a weight between 50 and 300 pounds.")
                End If
                    MessageBox.Show("Enter a height between 48 and 80 inches.")
                End If
                MessageBox.Show("Enter a age between 10 and 110 years")



        Catch ex As Exception

        End Try

    End Sub


End Class

Attachment 97787
Attached Images
 

Viewing all articles
Browse latest Browse all 27151

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>