' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
﻿Imports System
Imports System.Text

Namespace E
    Public Class Program
        Private Shared Sub VV(ByVal v As Integer)
            v = 456
        End Sub
        Public Shared Sub ValTypByVal()
            Dim v As Integer = 123
            VV(v)
            Console.WriteLine(v)
        End Sub
        Private Shared Sub VR(ByRef v As Integer)
            v = 456
        End Sub
        Public Shared Sub ValTypByRef()
            Dim v As Integer = 123
            VR(v)
            Console.WriteLine(v)
        End Sub
        Private Shared Sub RV1(ByVal sb As StringBuilder)
            sb.Append("DEF")
        End Sub
        Private Shared Sub RV2(ByVal sb As StringBuilder)
            sb = New StringBuilder("DEF")
        End Sub
        Public Shared Sub RefTypByVal()
            Dim sb As New StringBuilder("ABC")
            RV1(sb)
            Console.WriteLine(sb)
            RV2(sb)
            Console.WriteLine(sb)
        End Sub
        Private Shared Sub RR1(ByRef sb As StringBuilder)
            sb.Append("DEF")
        End Sub
        Private Shared Sub RR2(ByRef sb As StringBuilder)
            sb = New StringBuilder("DEF")
        End Sub
        Public Shared Sub RefTypByRef()
            Dim sb As New StringBuilder("ABC")
            RR1(sb)
            Console.WriteLine(sb)
            RR2(sb)
            Console.WriteLine(sb)
        End Sub
        Public Shared Sub Main(args As String())
            ValTypByVal()
            ValTypByRef()
            RefTypByVal()
            RefTypByRef()
        End Sub
    End Class
End Namespace
