top of page

The Code

 

 

 

 

Public Class Form1

    '## 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 sqroot(ByRef x As Single) As Double
       
'Exponent x = x ^ 0.5 - (Square Root Value of x)
        x = x ^ 0.5
        sqroot =
x
    End Function

    Private Function sqroot1(ByVal y As Single) As Double
       
'## Exponent y = y ^ 0.5 (Square Root Value of y)
        y = y ^ 0.5
        sqroot1 =
y
    End Function

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


        Dim u As Single
       
u = 9
        MsgBox(3 * sqroot(
u), , "ByRef")  
        MsgBox("
Value of u is " & u, , "ByRef")


    End Sub

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


        Dim u As Single
       
u = 9
        MsgBox(3 * sqroot1(
u), , "ByVal")
        MsgBox("
Value of u is " & u, , "ByVal")


    End Sub


End Class

 

Website Links-173.jpg
bottom of page