Friend

Friend

Friend. This modifier makes a member (like a Class, Sub or Function) unavailable outside the present assembly. An assembly is physical file that contains compiled code.

Here:
We specify that Display() is a Friend Sub. So it is Public inside the assembly, but not available outside.

VB.NET that uses Friend

Class Item
    Friend Sub Display()
        Console.WriteLine("Friend Class used")
    End Sub
End Class

Module Module1
    Sub Main()
        ' The Display Sub is public if we are in the same assembly.
        Dim local As Item = New Item()
        local.Display()
    End Sub
End Module

Output

Friend Class used

Comments

Popular posts from this blog

Error - vbe6ext.olb could not be loaded

Visual Studio $(TargetDir) macro is empty