Shane Partridge
Visual Basic 2013
The Code
Public Class MyClassPercentage_Increment
'## 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_Increment(ByVal Value As Single, ByVal DecimalPercent As Single)
'## Value = Value to be Multiplied by Decimal Percentage ------------------------------##
'## 1 = 1 Whole added to Decimal Percentage Value ------------------------------------##
'## (DecimalPercent / 100) = Percent Value displayed as Decimal Number-----------------##
'## Percentage_Increment = Mathematical Configuration ------------------------------##
Percentage_Increment = ((Value) * ((1 + (DecimalPercent / 100))).ToString(DecimalPlace)
End Function
End Class
Public Class Form101
Private Sub PercentageIncrementBtn_Click(sender As Object, e As EventArgs) Handles PercentageIncrementBtn.Click
'##=================Dimension Objects & Variables======================##
'## Dimension MyPercent_Increment as Object -------------------------------------------##
Dim MyPercentage_Increment As Object
'## MyPercent_Increment = MyClassPercentage_Increment() -------------------------------##
MyPercentage_Increment = New MyClassPercent_Increment()
'## 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 = (1 + (DecimalPercent / 100))
'## Assign Calculated Value to LblTotalCalculatedValue.Text ------------------------------------##
LblTotalCalculatedValue.Text = (MyPercentage_Increment.Percentage_Increment(Value, DecimalPercent))
'##==============================================================##
'##====================Catch Non_Numeric Exception=======================##
'## Try... Catch... End Try... Structure Non_NumericInput As Exception------------------------------##
Catch Non_NumericInput As Exception
'##===============================================================##
'##=================Program Flow SubRoutine 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 Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'## ========= Transfer Control back to Form97 Menu ============##
Form97.Show()
Me.Hide()
'## ===============================================================##
End Sub
Private Sub Form101_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