Structures: Your Own Data Types
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Structures: Your Own Data Types

You can combine data items of different types to create a structure. A structure associates one or more members with each other and with the structure itself. When you declare a structure, it becomes a composite data type, and you can declare variables of that type.

A structure is a generalization of the user-defined type (UDT) supported by previous versions of Visual Basic. In addition to fields, structures can expose properties, methods, and events. A structure can implement one or more interfaces, and you can declare individual accessibility for each field.

Structures are useful when you want a single variable to hold several related pieces of information. For example, you might want to keep an employee's name, telephone extension, and salary together. You could use several variables for this information, or you could define a structure and use it for a single employee variable. The advantage of the structure becomes apparent when you have many employees and therefore many instances of the variable.

In This Section

Structure Declaration
Shows how to declare a structure and its members.
Structure Variables
Covers assigning a structure to a variable and accessing its members.
Structures and Other Programming Elements
Summarizes how structures interact with arrays, objects, procedures, and each other.
Structures and Classes
Describes the similarities and differences between structures and classes.

Related Sections

Data Types
Introduces the Visual Basic .NET data types and describes how to use them.
Data Type Summary
Lists the elementary data types supplied by Visual Basic .NET.
© 2016 Microsoft