Shane Partridge
Visual Basic 2013
The Code
Public Class Form1
'## Dimension Values in Public Class - Global Variables ##
'## Scope of Variable Declaration = Public in Whole Program ##
'## Global Declaration of Variables - Used by Sub Routines ##
'## Sub Routines Assigned to Program ##
Dim FutureVal As Single
Dim PresentVal As Single
Dim interest As Single
Dim period As Integer
'## Formula Assigned in Private Function Mode ##
Private Function FV(pv As Single, i As Single, n As Integer) As Double
FV = pv * (1 + i / 100) ^ n
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'## Program Consists of (3) Sub Routines ##
'## Sub Routine (1) Assigns Values to Variable ##
'## Sub Routine (2) Calculates Value using Formula ##
'## Sub Routine (3) Assign Value to Label for View ##
'## Sub Routine(1) ##
AssignValues()
'## Sub Routine(2) ##
CalculateValue()
'## Sub Routine (3) ##
AssignLabelValue()
End Sub
'## Sub(1) ##
Sub AssignValues()
PresentVal = TextBox1.Text
interest = TextBox2.Text
period = TextBox3.Text
End Sub
'## Sub(2) ##
Sub CalculateValue()
FutureVal = FV(PresentVal, interest, period)
End Sub
'## Sub(3) ##
Sub AssignLabelValue()
Label1.Text = Format(FutureVal, "$#,##0.00")
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'## Close Program ##
Me.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'## Clear Text & Label Box Values ##
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
Label1.Text = ""
End Sub
End Class