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 149 views
1 answer 167 views
1 answer 198 views
1 answer 206 views
1 answer 198 views
198 views asked Mar 28, 2019 by avibootz
1 answer 217 views
217 views asked Mar 28, 2019 by avibootz
...