Appendix B. Variable Declarations and Data Types
This appendix provides information about variable declarations and data types.
Variable Declarations
The following code shows a standard variable declaration:
[attribute_list] [accessibility] [Shared] [Shadows] [ReadOnly] _ Dim [WithEvents]name[?] [(bounds_list)] [As [New]type[?]] _ [=initialization_expression]
The following list describes the pieces of this declaration:
attribute_list— A comma-separated list of attributes specific to a particular task. For example,<XmlAttributeAttribute(AttributeName:="Cost")>.accessibility—Public,Protected,Friend,Protected Friend,Private, orStatic.Shared— Means that all instances of the class or structure containing the variable share the same variable.Shadows— Indicates that the variable hides a variable with the same name in a base class.ReadOnly— Indicates that the program can read, but not modify, the variable's value. You can set the value in an initialization statement or in an object constructor.Dim— Officially tells Visual Basic that you want to create a variable. You can omit theDimkeyword if you specifyPublic,Protected,Friend,Protected Friend,Private,Static, orReadOnly.WithEvents— Tells Visual Basic that the variable is of a specific object type that may raise events that you will want to catch.name— Gives the name of the variable.?— Indicates this should be a nullable variable. For more information, see the section "Nullable Types" in Chapter 15, "Data Types, Variables, ...
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.
Read now
Unlock full access