Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio .NET
Reference
Declaration Changes
 Structure Declaration Changes in Vi...
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
Visual Basic Language Concepts
Structure Declaration Changes in Visual Basic

Visual Basic considers structures and user-defined types (UDTs) to be the same type of programming element. Visual Basic .NET updates structure declaration for unification and improved readability.

Visual Basic 6.0

In Visual Basic 6.0, you declare a structure using the Type ... End Type construction. The structure and its members all default to public access. Explicit access declaration is optional. The following example shows a valid structure declaration:

Type Employee 
   EmpNumber As Integer     ' Defaults to Public access. 
   EmpOfficePhone As String 
   EmpHomePhone As String   ' Cannot be declared Private inside Type. 
End Type 

Visual Basic .NET

In Visual Basic .NET, the Type statement is not supported. You must declare structures using the Structure statement as part of a Structure ... End Structure construction. Every member of a structure must have an access modifier, which can be Public, Friend, or Private. You can also use the Dim statement, which defaults to public access. The structure in the preceding example can be declared as follows:

Structure Employee 
   Public EmpNumber As Integer     ' Must declare access, even if Public. 
   Dim EmpOfficePhone As String    ' Still defaults to Public access. 
   Private EmpHomePhone As String  ' Can be made Private inside Structure. 
End Structure  

Visual Basic .NET unifies the syntax for structures and classes. Structures support most of the features of classes, including methods.

See Also

Structure Statement | Dim Statement | Public | Private | Programming Element Support Changes Summary

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker