top of page

The Code

 

 

 

 

Public Class Form1

    '## Scope of Declaration = Public Class assessable to Whole Program
    '## Sub Routine Program Flow - Variable = Assessable by Public Class

    '## Variable (u) Function = ByRef
    Dim u As Single = 9

    '## Variable (u1) Function = ByVal
    Dim u1 As Single = 9

    '## Functions can be called by (Value) or called by (Reference)
    '## By default, the Arguments are passed by (Reference).
    '## Original Data will be modified and (No Longer Preserved).
    '## On one Hand, if Arguments are passed by (Value), original
    '## Data will be preserved. The keyword to pass Arguments
    '## By (Reference) is (ByRef) and the keyword to pass Arguments 
    '## by (Value) is (ByVal).

    '## Example :
    '## Private Function FV(ByVal PV AS Single, ByRef i as Single, n as Integer) as Double

    Private Function Power(ByRef x As Single) As Double

        'Exponential x = x ^ 2 - (Equation Power ( x^2 ) )
        x = x ^ 2
       
Power = x
    End Function

    Private Function Power1(ByVal y As Single) As Double
       
'## Exponential y = y ^ 2 (Equation Power ( y^2 ) )
        y = y ^ 2
       
Power1 = y
    End Function

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click

        '## Subrountine Program Flow Orientation ##


        '## Sub Routine (1) ##
        '## Calculus = ByRef (By Reference)
        '## Original Data will be Modified by Calculus ##

        PowerByReference()

        '## Sub Routine (2) ##
        '## Calculus = ByVal (By Value)
        '## Original Data being preserved ##

        PowerByValue()

    End Sub

    '## Sub(1) ##
    Sub PowerByReference()
       
Label1.Text = (3 * Power(u))
       
Label2.Text = u
    End Sub

    '## Sub(2) ##
    Sub PowerByValue()
       
Label3.Text = (3 * Power1(u1))
       
Label4.Text = u1
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        '## Clear Label Text ##
        Label1.Text = ""
        Label2.Text = ""
        Label3.Text = ""
        Label4.Text = ""
       
u = 9 : u1 = 9

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        '## Close Program ##
        Me.Close()

    End Sub

End Class
 

Website Links-173.jpg
bottom of page