Data Types in Visual BasicĀ
The data type of a programming element refers to what kind of data it can hold and how it stores that data. Data types apply to all values that can be stored in computer memory or participate in the evaluation of an expression. Every variable, literal, constant, enumeration, property, procedure parameter, procedure argument, and procedure return value has a data type.
Declared Data Types
Unless you use typeless programming, you must declare data types for all your programming elements. (For more information, see Typeless Programming in Visual Basic.)
You define a programming element with a declaration statement, and you specify its data type with the As clause. The following table shows the statements you use to declare various elements.
Programming element | Data type declaration |
---|---|
Variable |
In a Dim Statement (Visual Basic)
|
Literal |
With a literal type character; see "Literal Type Characters" in Type Characters
|
Constant |
In a Const Statement (Visual Basic)
|
Enumeration |
In an Enum Statement (Visual Basic)
|
Property |
In a Property Statement
|
Procedure parameter |
In a Sub Statement (Visual Basic), Function Statement (Visual Basic), or Operator Statement
|
Procedure argument |
In the calling code; each argument is a programming element that has already been declared, or an expression containing declared elements
|
Procedure return value |
In a Function Statement (Visual Basic) or Operator Statement
|
See Also
Tasks
Reference
Data Type Summary (Visual Basic)
Concepts
Type Characters
Composite Data Types
Generic Types in Visual Basic
Typeless Programming in Visual Basic
Other Resources
Elementary Data Types
Data Type Implementation
Type Conversions in Visual Basic
Structures: Your Own Data Types