top of page
The Code
Website Links-173.jpg

Public Class MyClassMultiply_FormulaApplications

    '## [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-##

    '## =========Multiply_Formula Applications ==================== ##


    '## Public Class Module MyClassMultiply_FormulaApplications ##
    '## ------Contains a List of Formula Applications----------- ##
    '## -- Class Modules can be used for Program Applications -- ## 

 

    '## =====   =Decimal Place Precision [2] ============ ##

    Dim DecimalPlace as string = "n2"

    '## ===================================== ##


    '## ============== Area of Square Formula ======= ##
    '## -------- Area of Square = 6 x (Side^2) ----------------- ##


    Public Function AreaSquare_Formula(ByVal Side as Single)
       
AreaSquare_Formula = (6 * (Side ^ 2)).ToString(DecimalPlace)
    End Function
   
'## ===================================== ##


    '## ============== Volume of Sphere ====================== ##
    '## ------- Volume of Sphere = ((4/3) * (PI) * (Radius ^3 )) ------------------ ##

    '## ------- Value of [PI] = 3.14 or [22/7] ------------------------------------##


    Public Function SphereVolume_Formula(ByVal Radius as Single)
       
SphereVolume_Formula = ((4 / 3) * (22 / 7) * (Radius ^ 3)).ToString(DecimalPlace)
    End Function
   
'## ================================================= ##


    '## ============= Area of Sphere ===================== ##
    '## --------- Area = ((4) * (PI) * (Radius ^ 2)) ------------------------- ##

    '## ------- Value of [PI] = 3.14 or [22/7] ------------------------------ ##


    Public Function AreaSphere_Formula(ByVal Radius as Single)
       
AreaSphere_Formula = ((4) * (22 / 7) * (Radius ^ 2)).ToString(DecimalPlace)
    End Function
   
'## ============================================= ##


End Class
 

Public Class Form108

    
    Private Sub CalculateBtn_Click(sender As Object, e As EventArgs) Handles CalculateBtn.Click

 

        '## =========== Dimension Objects and Variables =================== ##
        '## ==== Dimension Square Formula as Object ================ =======##

        Dim MyAreaSquare_Formula As Object
       
'## =================================================== ##

 

        '## MyAreaSquare_Formula = MyClassMultiply_FormulaApplications ##
        MyAreaSquare_Formula = New MyClassMultiply_FormulaApplications()
        '## ====================================================##

 


        '## ========== Assign Label Error Format =========================##
        '## Reset Lbl_Answer.Text Forecolor to Blue -------------------------------------##

        LblSurfaceArea.ForeColor = Color.Blue
       
'## =====================================================##

 


        '##============== Assign Error HANDLING ========================##
        '## Try... Catch... End Try... Structure -----------------------------------------------##
        '## Error Handling Routine -------------------------------------------------------##

        Try
         
  '##===================================================##

 

 

            '## =============== Dimension Side as Single ================== ##
            Dim Side As Single
           
'#  ---------- Assign Variable to TextBox Input ---------------- ----------------#
            Side = TxtLengthofSides.Text
            '## ===================================================#

 

 

 


            '## ===== Assign Value to Label.Text for Area Calculus ================ ##
            LblSurfaceArea.Text = (MyAreaSquare_Formula.AreaSquare_Formula(Side))
           
'## =================================================== ##

 

 

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

        Catch Non_NumericInput As Exception
           
'##===================================================##

 

 

 


            '##=================Program Flow SubRoutine [1] Error Handling======## 
            '## Catch Non Numeric Input as Error ------------------------------------------##

            NonNumericInput()
           
'##====================================================##

 

            '##======================== End Try [Error Handling] ============##
       
End Try
       
'##======================================================##

 

 


    End Sub

 


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

    Sub NonNumericInput()
       
LblSurfaceArea.ForeColor = Color.Red
        LblSurfaceArea.Text = "Error"
       
'## ===================================================== ##

 


        End sub

 


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

        '## ============= Clear Text & Label Boxes =======================##
        '## Clear Text and Label Boxes for Re-Evaluation ---------------------------------##

        LblSurfaceArea.Text = ""
       
TxtLengthofSides.Text = ""
        
       
'##=====================================================##

    End Sub


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


        '## ====== Delete Label Box Names at Start up Procedure ================##
        LblSurfaceArea.Text = ""
       
'## ====================================================##


    End Sub

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

 

        '## ========= Transfer Control back to Form105 Menu =================## 
        Form105.Show()
        Me.Hide()
       
'## ====================================================##

 

    End Sub

 

End Class

bottom of page