top of page

The Code

 

 

 

 

 

 

Public Class MyClassFahrenheit_CelsiusConversion

    '## Temperature Conversion MyClassFahrenheit_CelsiusConversion -------------##
    '## [1]Encapsulation - Self Contained Modules ---------------------------------##
    '## [2]Inheritance - Structured Class to be passed by Hierarchy Inheritance -------##
    '## [3]Polymorphism - Modules represent Real World Objects known as Classes ---##

  '## Dimension DecimalPlace as String = "n2" Number Decimal Place = 2 -----------##

    Dim DecimalPlace As String = "n2"

    Public Function Fahrenheit_Celsius(ByVal Celsius As Integer)

        '## Mathematical Conversion Parameters -------------------------------------##
        Fahrenheit_Celsius = ((Celsius * (9 / 5)) + 32).ToString(DecimalPlace)
    End Function


    Public Function Celsius_Fahrenheit(ByVal Fahrenheit As Integer)

        '## Mathematical Conversion Parameters -------------------------------------##
        Celsius_Fahrenheit = ((Fahrenheit - 32) * (5 / 9)).ToString(DecimalPlace)
    End Function

End Class

 

Public Class Form100

   Private Sub TemperatureConversion_Click(sender As Object, e As EventArgs) Handles TemperatureConversion.Click


        '## Dimension MyFahrenheit_Celsius as Object of MyClassFahrenheit_CelsiusConversion.vb  ##
        Dim MyFahrenheit_Celsius As Object

        '## Dimension MyCelsius_Fahrenheit as object of MyClassFahrenheit_CelsiusConversion.vb  ##
        Dim MyCelsius_Fahrenheit As Object

        '## Dimension Fahrenheit & Celsius as Integer Values----------------------------------- ##
        Dim Fahrenheit, Celsius As Integer

        '## Declare Lbl_ErrMsg as Invisible ----------------------------##
        LblErrorMessage.Visible = False
       
'## Reset Lbl_Answer.Text Forecolor to Blue --------------------##
        LblCelsius_Fahrenheit.ForeColor = Color.Blue
       
LblFahrenheit_Celsius.ForeColor = Color.Blue


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

        Try

        '## (MyFahrenheit_Celsius) Inheritance of (MyClassFahrenheit_CelsiusConversion()  )-----##
        '## (MyCelsius_Fahrenheit) Inheritance of (MyClassFahrenheit_CelsiusConversion()  )-----##
        '## Calculation Temperature Conversions ------------------------------------------------##

        MyFahrenheit_Celsius = New MyClassFahrenheit_CelsiusConversion()
        MyCelsius_Fahrenheit = New MyClassFahrenheit_CelsiusConversion()

        '## Assign Values to Text.Box Input for Temperature Conversion ##
       
Celsius = TXTFahrenheit_Celsius.Text
        Fahrenheit = TXTCelsius_Fahrenheit.Text

        '## Celsius is an Instance of the MyFahrenheit_CelsiusConversion.vb Class ------------##
        '## Fahrenheit is an Instance of the MyFahrenheit_ClesiusConversion.vb Class--------- ##
        '## Ordained by Hierachial Step Inheritance of MyFahrenheit_CelsiusConverion.vb Class ##

        '## Assign Conversion Values to Label.Text Boxes -----------------------------------##
        LblFahrenheit_Celsius.Text = (MyFahrenheit_Celsius.Fahrenheit_Celsius(Celsius))
       
LblCelsius_Fahrenheit.Text = (MyCelsius_Fahrenheit.Celsius_Fahrenheit(Fahrenheit))

            '## Try... Catch... End Try... Structure Non_NumericInput As Exception---------------##

Catch Non_NumericInput As Exception
           
'## Subroutine[1] NonNumeric() ------------------------------------------------##

            '## Catch Non Numeric Input as Error -------------------------------------------##
            NonNumericInput()

        End Try

    End Sub

  '## Sub[1] -------------------------------------------------------##
    '## Error Handling Message Routine -------------------------------##
    '## Show Error Msg in Label (LblCelsius_Fahrenheit.Text) ---------##
    '## Show Error Msg in Label (LblFahrenheit_Celsius.Text) ---------##

    Sub NonNumericInput()
       
LblCelsius_Fahrenheit.ForeColor = Color.Red
       
LblFahrenheit_Celsius.ForeColor = Color.Red
       
LblCelsius_Fahrenheit.Text = "Error"
       
LblFahrenheit_Celsius.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 Clear_Click(sender As Object, e As EventArgs) Handles Clear.Click

        '## Clear Text and Label Boxes for Re-Evaluation -------------##
        TXTFahrenheit_Celsius.Text = ""
       
TXTCelsius_Fahrenheit.Text = ""
       
LblFahrenheit_Celsius.Text = ""
       
LblCelsius_Fahrenheit.Text = ""
       
LblErrorMessage.Text = ""

    End Sub

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

        '## Omitt Label.Text Boxes as Invisible = Null String "" Handles MyBase.Load-----##
        LblFahrenheit_Celsius.Text = ""
       
LblCelsius_Fahrenheit.Text = ""
       
LblErrorMessage.Text = ""

    End Sub

 

    Private Sub IndexForm97_Click(sender As Object, e As EventArgs) Handles IndexForm97.Click

        '## Show Form97 Menu ------------------------------------------------------##
        Form97.Show()
        Me.Hide()

    End Sub


End Class

Website Links-173.jpg
bottom of page