top of page

The Code

 

 

 

 

Public Class MyClassPercent_Decrement

    '## Percentage Increment MyClassMyClassPercentageIncrement---- ----------------------##
    '## [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------------##
    '## Set Decimal Place to n2 Places -----------------------------------------------------##

    Dim DecimalPlace As String = "n2"

    Public Function Percentage_Decrement(ByVal Value As Single, ByVal DecimalPercent As Single)

        '## Percentage_Decrement = (Value x ((100 - DecimalPercent) / 100))--------------------##
        '## Percentage_Increment = Mathematical Configuration ------------------------------##

        Percentage_Decrement = ((Value) * ((100 - DecimalPercent) / 100)).ToString(DecimalPlace)

    End Function

 

 

 

Public Class Form102

    

    Private Sub PercentDecrement_Click(sender As Object, e As EventArgs) Handles PercentDecrement.Click

 


        '##=================Dimension Objects & Variables========================## 
        '## Dimension MyPercent_Increment as Object ---------------------------------------------## 

        Dim MyPercentage_Decrement As Object

        '## MyPercent_Increment = MyClassPercentage_Increment() --------------------------------##
        MyPercentage_Decrement = New MyClassPercent_Decrement()

        '## Dimension Value, DecimalPercent as Single Precision -------------------------------------##
        Dim Value, DecimalPercent As Single


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

        '## ========== Assign Label Error Format =================================##
        '## Declare Lbl_ErrMsg as Invisible ----------------------------------------------------------##

        LblErrorMessage.Visible = False


        '## Reset Lbl_Answer.Text Forecolor to Blue --------------------------------------------------##
        LblCurrentValue.ForeColor = Color.Blue
       
LblPercentageValue.ForeColor = Color.Blue
       
LblTotalCalculatedValue.ForeColor = Color.Blue


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


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

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


            '##============= Assign Numeric TextBox Values =============================##
            '## Assign Numeric Values to Variables --------------------------------------------------------##

            Value = TxtValue.Text
            DecimalPercent = TxtPercentageValue.Text
            '##===============================================================##


            '## ================Arithmetic Values to Label Boxes==========================##
            '## Assign Arithmetic Values to LblText.Box ------------------------------------------------------##

            LblCurrentValue.Text = Value
            LblPercentageValue.Text = ((100 - DecimalPercent) / 100)

            '## Assign Calculated Value to LblTotalCalculatedValue.Text ----------------------------------------##
            LblTotalCalculatedValue.Text = (MyPercentage_Decrement.Percentage_Decrement(Value, DecimalPercent))
           
'##================================================================##


            '##====================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()
       
LblCurrentValue.ForeColor = Color.Red
        LblPercentageValue.ForeColor = Color.Red
        LblTotalCalculatedValue.ForeColor = Color.Red

        LblCurrentValue.Text = "Error"
       
LblPercentageValue.Text = "Error"
       
LblTotalCalculatedValue.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

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

        TxtValue.Text = ""
       
TxtPercentageValue.Text = ""
       
LblCurrentValue.Text = ""
       
LblPercentageValue.Text = ""
       
LblTotalCalculatedValue.Text = ""
       
LblErrorMessage.Text = ""
       
'##===================================================================##

 

    End Sub


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

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


    End Sub

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

        '## ====== Delete Label Box Names at Start up Procedure =============================##
        LblCurrentValue.Text = ""
       
LblPercentageValue.Text = ""
       
LblTotalCalculatedValue.Text = ""
       
LblErrorMessage.Text = ""
       
'## ==================================================================##

    End Sub

End Class

 

Website Links-173.jpg
bottom of page