top of page

The Code

 

 

 

Website Links-173.jpg

Public Class MyClassBodyMassIndex


    '## Object Orientated Programming [MyClassBodyMassIndex]------------------##
    '## Inheritance : Inherited Program Structure to Public Class Form98-----------##
    '## Polymorphism : SubClass Structure = Weight & Height Instance of Class ----##


    Public Function BMI(ByVal height As Single, ByVal weight As Single)
       
BMI = Format((weight) / (height ^ 2), "0.00")


    End Function


End Class

Public Class Form98

  Private Sub BMICalculateBtn_Click(sender As Object, e As EventArgs) Handles BMICalculateBtn.Click

        '## Dimension MyHypotenuse as Object of MyClassHypotenuse.vb ##
        Dim MyBodyMassIndex As Object

        '## Dimension Side Variables as Numeric Integer---------------##
        Dim Height, Weight As Single

        '## Declare Lbl_ErrMsg as Invisible --------------------------##
        LblErrorMessage.Visible = False


        '## Reset Lbl_Answer.Text Forecolor to Blue ------------------##
        LblBMIScore.ForeColor = Color.Blue

        '## Try... Catch... End Try... Stucture ----------------------##
        '## Error Handling Routine -----------------------------------##

        Try

            '## MyHypotenuse Inheritance of MyClassHypotenuse --------##
            '## Calculate Hypotenuse ---------------------------------##

            MyBodyMassIndex = New MyClassBodyMassIndex()
            Height = TxtBMIHeight.Text
            Weight = TxtBMIWeight.Text
            LblBMIScore.Text = ((MyBodyMassIndex.BMI(Height, Weight)))

        Catch Non_Numeric As Exception
           
'## Subroutine[1] NonNumeric() ------------------------##
            '## Catch Non Numeric Input as Error ------------------##

            NonNumeric()

        End Try

    End Sub

    '## Sub[1] ---------------------------------------------------##
    '## Error Handling Message Routine ---------------------------##

    Sub NonNumeric()
     
  LblBMIScore.ForeColor = Color.Red
       
LblBMIScore.Text = "Error"
       
'## Declare Lbl_ErrMsg as Visible ------------------------##
        LblErrorMessage.Visible = True
       
LblErrorMessage.ForeColor = Color.Red
       
LblErrorMessage.Text = " One of the entries is not a number! Try again!"


    End Sub


    Private Sub ClearBtn_Click(sender As Object, e As EventArgs) Handles ClearBtn.Click

        '## Text.Boxes and Text.Lables -----------------------------##
        TxtBMIHeight.Text = ""
       
TxtBMIWeight.Text = ""
       
LblBMIScore.Text = ""
       
LblErrorMessage.Text = ""

    End Sub

    Private Sub Form98_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        '## Declare Visible = False as Null String[""]------------- ##
        '## Label.Text Boxes in Form.vb Design = Invisible ---------##

        LblBMIScore.Text = ""
       
LblErrorMessage.Text = ""

    End Sub

    Private Sub IndexBtn_Click(sender As Object, e As EventArgs) Handles IndexBtn.Click

        '## IndexBtn back to Index Menu -----------------------------##
       
Form97.Show()
        Me.Hide()

    End Sub

End Class

bottom of page