JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using Friend Access

The scope of public members is unlimited, but you also can give members friend scope, which restricts them to the current program (that is, the program that contains their declaration) and anywhere else in the same assembly (public members, by contrast, are available across assemblies). You can use the Friend keyword in these statements:

  • Class Statement

  • Const Statement

  • Declare Statement

  • Dim Statement

  • Enum Statement

  • Event Statement

  • Function Statement

  • Interface Statement

  • Module Statement

  • Property Statement

  • Structure Statement

  • Sub Statement

You can declare friend access just like any other access modifier; here's an example:

Public Class Displayer
    Friend Sub Display(ByVal Text As String)
        MsgBox(Text)
    End Sub
End Class

Dim displayer As New displayer()
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    displayer.Display("Hello from Visual Basic!")
End Sub
Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor