top of page
The Code
Visual Basic 2013 Adobe-p054.jpg
Website Links-173.jpg
download (3).png
Earth's Radius = 6,371 km
Earth's Surface Area^2 =
510 Million    269 Thousand   772.57 Km^2

Public Class MyClassMultiply_FormulaApplications


    '## ============================ Public Class Functions ======##
    '## [1]Encapsulation - Self Contained Modules -------------------------------##
    '## [2]Inheritance - Structured Class to be passed by Hierarchy Inheritance -----##
    '## Inheritance lets you focus on adding unique application features.You don't --##
    '## have to keep reinventing the wheel by rewriting existing code repeatedly. ---##

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

 

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


    '## ============= Surface Area of Sphere ===================== ##
    '## --------- Area = ((4) * (PI) * (Radius ^ 2)) -------------------------------- ##
    '## --------- Value of [PI] = 3.14 or [22/7] ----------------------------------- ##

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


End Class

Public Class Form110

    

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

        '## =========== Dimension Objects and Variables ===================##
        '## ==== Dimension Surface Area as Object =========================##

        Dim MySurfaceAreaSphere_Formula As Object
       
'## ====================================================##

 

        '## MySphereVolume_Formula = MyClassMultiply_FormulaApplications ======== ##
        MySurfaceAreaSphere_Formula = New MyClassMultiply_FormulaApplications()
        '## ====================================================##

 


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

        LblSphereSurfaceArea.ForeColor = Color.Blue
       
'## ===================================================##

 

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

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

 


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


            '## ===== Assign Value to Label.Text for Area Calculus ========================= ##
            LblSphereSurfaceArea.Text = (MySurfaceAreaSphere_Formula.SurfaceAreaSphere_Formula(Radius))
         
  '## =========================================================== ##

 

            '##============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()

        LblSphereSurfaceArea.ForeColor = Color.Red
        LblSphereSurfaceArea.Text = "Error : entry is not a number!"
       
'##============================================##


        

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

        TxtRadiusofSphere.Text = ""
       
LblSphereSurfaceArea.Text = ""

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

 

    End Sub

 

    Private Sub Index105Btn_Click(sender As Object, e As EventArgs) Handles Index105Btn.Click

        '## ====== Revert to Index Form 105 ============================ ##
        Form105.Show()
        Me.Hide()
       
'## =================================================== ##

    End Sub

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

        '## ========Clear Labels at Initial Startup Procedure================== ##
        LblSphereSurfaceArea.Text = ""
     
  '## =================================================== ##

    End Sub

End Class

bottom of page