O'Reilly logo

VB & VBA in a Nutshell: The Language by Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Type Statement

Named Arguments

No

Syntax

[Private | Public] Type varname
						elementname [([subscripts])] As type
   [elementname [([subscripts])] As type]
   . . .
End Type

Public

Use: Optional

Type: Keyword

Gives the user-defined type scope through all procedures in all modules in the project. Public and Private are mutually exclusive.

Private

Use: Optional

Type: Keyword

Restricts the scope of the user-defined type to those procedures within the same module. Public and Private are mutually exclusive.

varname

Use: Required

The name of the user-defined type.

elementname

Use: Required

Data Type: Any

The name of an element of the user-defined type.

subscripts

Use: Optional

Data Type: Numeric literal or constant

The dimensions of an array element.

type

Use: Required

The data type of the element.

Description

Used at module level to define a user-defined type.

Rules at a Glance

  • A user-defined type can contain one or more elements.

  • The Type statement can't be used within a procedure; it can be used only within the declaration section of a module.

  • In form and code modules, user-defined types are Public by default. You can reduce the scope and visibility of a user-defined type to the current module by using the Private keyword.

  • Until Version 6 of VB, publicly declared user-defined types were not permitted in class modules. Now, VB6 has introduced the remote user-defined types, which allow you to declare a property as a user-defined type, or have a class method return a user-defined type. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required