Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Dim Statement

Syntax

[accessmodifier] [Shared] [Shadows] [readonly] Dim [WithEvents] _ varname[([subscripts])] _
             [As [New] type] [= initexpr]
accessmodifier (optional; Keyword)

Can be one of Public, Protected, Friend, Protected Friend, Private, or Static. If one of these is included, the Dim keyword can be omitted.

Shared (optional; Keyword)

Indicates the the variable is not associated with any particular class instance but is accessible directly using the class name and is therefore “shared” by all class instances.

Shadows (optional; Keyword)

Indicates that the variable shadows any programming elements (variables, procedures, enums, constants, etc.) of the same name in a base class.

WithEvents (optional; Keyword)

In an object variable definition, indicates that the object will receive event notification

varname (required)

The name of the variable

subscripts (optional)

Dimensions of an array variable

New (optional; Keyword)

Keyword that creates an instance of an object

type (optional unless Option Strict is On)

The data type of varname

initexpr (optional)

Any expression that provides the initial value to assign to the variable; cannot be used if an As New clause is used

Description

Declares and allocates storage space in memory for variables. The Dim statement is used either at the start of a procedure or the start of a module to declare a variable of a particular data type.

Rules at a Glance

  • Public, Friend, Shared, Shadows, and ReadOnly can only be used at the module, namespace, ...

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

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata