Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

Byref and Byval

I would like someone to give me a simple and clear illustration of using Byval and Byref in VB example.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

I guess I figured it out ...

Private Sub calculatesum(ByVal numb1 As Integer, ByVal numb2 As Integer, ByVal totalsum As Integer)
        totalsum = totalsum + numb1 + numb2
        MsgBox(totalsum)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim x, y, z
        x = 5
        y = 5
        z = 7
        Me.calculatesum(x, y, z)
        MsgBox(x)
        MsgBox(y)
        MsgBox(z)

    End Sub
Avatar of jskfan

ASKER

thanks, your example is much more simple and clear.