Data Types in Visual Basic


Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

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.

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 elementData type declaration
VariableIn a Dim Statement

 Dim   amount As Double

 Static   yourName As String

 Public   billsPaid As Decimal = 0
LiteralWith a literal type character; see "Literal Type Characters" in Type Characters

 Dim searchChar As Char = "."  C
ConstantIn a Const Statement

 Const   modulus As Single = 4.17825F
EnumerationIn an Enum Statement

 Public   Enum   colors
PropertyIn a Property Statement

 Property   region() As String
Procedure parameterIn a Sub Statement, Function Statement, or Operator Statement

 Sub addSale(ByVal   amount   As Double)
Procedure argumentIn the calling code; each argument is a programming element that has already been declared, or an expression containing declared elements

 subString = Left(  inputString  ,   5  )
Procedure return valueIn a Function Statement or Operator Statement

 Function convert(ByVal b As Byte)   As String

For a list of Visual Basic data types, see Data Types.

Type Characters
Elementary Data Types
Composite Data Types
Generic Types in Visual Basic
Value Types and Reference Types
Type Conversions in Visual Basic
Troubleshooting Data Types
Data Types
Efficient Use of Data Types