Skip to Content
Programming Visual Basic .NET
book

Programming Visual Basic .NET

by Dave Grundgeiger
December 2001
Beginner
464 pages
13h 51m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET

Access Modifiers

Access modifiers control the accessibility of types (including enumerations, structures, classes, standard modules, and delegates) and type members (including methods, constructors, events, constants, fields [data members], and properties) to other program elements. They are part of the declarations of types and type members. In the following code fragment, for example, the keywords Public and Private are access modifiers:

Public Class SomeClass
 
   Public Sub DoSomething(  )
      ' ...
   End Sub
 
   Private Sub InternalHelperSub(  )
      ' ...
   End Sub
   
End Class

The complete list of access modifiers and their meanings is shown in Table 2-5.

Table 2-5. Access modifiers

Access modifier

Description

Friend

Defines a type that is accessible only from within the program in which it is declared.

Private

Defines a type that is accessible only from within the context in which it is declared. For instance, a Private variable declared within a class module is accessible only from within that class module. A Private class is accessible only from classes within which it is nested.

Protected

Applies to class members only. Defines a type that is accessible only from within its own class or from a derived class.

Protected Friend

Defines a type that is accessible from within the program in which it is declared as well as from derived classes.

Public

Defines a type that is publicly accessible. For example, a public method of a class can be accessed from any program that instantiates ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Visual Basic .NET, Second Edition

Programming Visual Basic .NET, Second Edition

Jesse Liberty

Publisher Resources

ISBN: 0596000936Supplemental ContentCatalog PageErrata