Shane Partridge
Visual Basic 2013
The Code
Battle of Pinkie Cleugh 1547
Partridge Genealogy
Date Calculus
Public Class MyClassDateInterval_DayConversion
'## ===== 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 -------------- ##
'## Date Interval Conversion (Assign ByVal Variable as Date) ----------------------------------- ##
Public Function DateInterval_DayConversion(ByVal CalculateFirstDate As Date, ByVal CalculateSecondDate As Date)
DateInterval_DayConversion = DateDiff(DateInterval.Day, CalculateFirstDate, CalculateSecondDate)
End Function
End Class
Public Class Form112
'## ============ Sub Routine Configuration ======================== ##
'## --------- Declare Variables as Public Class -------------------------------------- ##
'## ======== Declare First Date Variables ============================ ##
'## ======== String(Date) to Cdate(Numeric Calculus) ==================== ##
'## CalculateFirstDate as Cdate(FirstDate) ============================== ##
Dim FirstDate As String
Dim CalculateFirstDate As Date
'## ======================================================= ##
'## ======== Declare Second Date Variables =========================== ##
'## ======== String(Date) to Cdate(Numeric Calculus) ===================== ##
'## CalculateSecondDate as Cdate(SecondDate) =========================== ##
Dim SecondDate As String
Dim CalculateSecondDate As Date
'## ======================================================== ##
'## ======= Declare Variables as Numeric Configuration ===================== ##
'## === (DTD = Date Total Days) ------------------------------------------------------ ##
Dim DTD As Integer
'## === CountDays = Math.Abs(DTD * 1) ----------------------------------------------- ##
Dim CountDays As Integer
'## === TotalYears = (CountDays / 365) ----------------------------------------------- ##
Dim TotalYears As Single
'## ========================================================= ##
'## =========== Decimal Place Configuration ============================ ##
'## ------- TotalYears = (CountDays / 365) (Decimal Value) = =====================##
'## ====== TotalYears.ToString(DecimalPlace) =============== ===============##
Dim DecimalPlace As String = "n2"
'## ========================================================== ##
'## ========== Object Orientated Programming =========================== ##
'## ========== Declare Class Object =================================== ##
'## MyCalculus_DateTime = New MyClassDateInterval_DayConversion ##
Dim MyCalculus_DateTime As Object
'## =========================================================== ##
Private Sub BtnCalculateDateDiff_Click(sender As Object, e As EventArgs) Handles BtnCalculateDateDiff.Click
'## Private Sub BtnCalculateDateDiff_Click ##
'## Consists of Three Subroutines ========================================== ##
'## Sub Rountine(1) ------ ##
'## Input Date for Calculus ##
InputDateValue()
'## Sub Routine(2) --------- ##
'## Calculate Days Difference ##
InputCalculateDays()
'## Sub Rountine(3) ------- ##
'## Assign Values to Labels ##
InputAssigntoLabels()
End Sub
' ## Sub(1) ================================ ##
' ## Assign Values to Variables for Calculus --------------- ##
Sub InputDateValue()
FirstDate = TxtFirstDate.Text
CalculateFirstDate = CDate(FirstDate)
SecondDate = TxtSecondDate.Text
CalculateSecondDate = CDate(SecondDate)
' ## ==================================== ##
End Sub
' ## Sub(2) ##
' ## Object Orientated Programming ======================================= ##
' ## Calculate Day Differences as Numeric Value ================================ ##
' ## Math.Abs(Value) = (+/-) Date Input ===================================== ##
Sub InputCalculateDays()
MyCalculus_DateTime = New MyClassDateInterval_DayConversion
DTD = (MyCalculus_DateTime.DateInterval_DayConversion(CalculateFirstDate, CalculateSecondDate))
CountDays = Math.Abs(DTD * 1)
TotalYears = (CountDays / 365)
'## =========================================================== ##
End Sub
' ## Sub(3) ##
' ## Assign Valuea to Label.Box Graphic Display ============== ##
Sub InputAssigntoLabels()
'## CountDays Format = "Standard" (ie - 172,456.00) ========= ##
'## CountDays Declared as Integer Value ================= ##
LblDaysCalculated.Text = Format(CountDays, "Standard")
LblYearsCalculated.Text = TotalYears.ToString(DecimalPlace)
' ## ======================================== ##
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 BtnClear_Click(sender As Object, e As EventArgs) Handles BtnClear.Click
'## Clear Label & TextBox Content ##
LblDaysCalculated.Text = ""
LblYearsCalculated.Text = ""
TxtFirstDate.Text = ""
TxtSecondDate.Text = ""
'## ===================- ##
End Sub
End Class