How to use ByVal and ByRef with subroutine (sub) in VB.NET

1 Answer

0 votes
Module Module1

    Sub Main()

        Dim n As Integer = 0

        sub1(n)
        Console.WriteLine(n)

        sub2(n)
        Console.WriteLine(n)

    End Sub

    Sub sub1(ByVal n As Integer)
        n = 13
    End Sub

    Sub sub2(ByRef n As Integer)
        n = 99
    End Sub

End Module


' run:
' 
' 0
' 99

 



answered Oct 19, 2018 by avibootz

Related questions

1 answer 159 views
1 answer 179 views
1 answer 207 views
1 answer 221 views
1 answer 212 views
212 views asked Mar 28, 2019 by avibootz
1 answer 230 views
230 views asked Mar 28, 2019 by avibootz
...