Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,987 questions

51,931 answers

573 users

How to use ByVal and ByRef in with variable VB.NET

1 Answer

0 votes
Module Module1

    Sub Main()

        Dim n As Integer = 5

        s(n)
        Console.WriteLine(n)

        s_byval(n)
        Console.WriteLine(n)

        s_byref(n)
        Console.WriteLine(n)

    End Sub

    Sub s(n As Integer) ' ByVal is the default
        n = 111
    End Sub

    Sub s_byval(ByVal n As Integer)
        n = 222
    End Sub

    Sub s_byref(ByRef n As Integer)
        n = 333
    End Sub

End Module

'run:
' 
' 5
' 5
' 333

 



answered Mar 2, 2016 by avibootz

Related questions

1 answer 218 views
1 answer 141 views
1 answer 167 views
1 answer 212 views
2 answers 218 views
1 answer 143 views
1 answer 163 views
...