Skip to content
AgileLogics
5 min read

Data Types

Prerequisites: Variables and constants

Every variable has a type that decides what values it can hold. The everyday types:

Type Example Notes
Integer 42 32-bit whole number
Long 42L 64-bit whole number
Double 3.14 64-bit floating point
Decimal 19.99D exact decimal, for money
Boolean True True or False
Char "A"c a single character
String "hello" text
Date #3/9/2025# date and time (System.DateTime)
Object anything the base type of all types
Module Program
    Sub Main()
        Dim count As Integer = 42
        Dim big As Long = 9_000_000_000L
        Dim ratio As Double = 0.75
        Dim price As Decimal = 19.99D
        Dim isReady As Boolean = True
        Dim grade As Char = "A"c
        Dim greeting As String = "hello"
        Dim launch As Date = #3/9/2025#

        Console.WriteLine($"{count} {big} {ratio} {price} {isReady} {grade} {greeting}")
        Console.WriteLine(launch.ToString("yyyy-MM-dd"))
        Console.WriteLine(Integer.MaxValue)
        Console.WriteLine(price.GetType().FullName)
    End Sub
End Module
42 9000000000 0.75 19.99 True A hello
2025-03-09
2147483647
System.Decimal
  • VB type names are aliases for .NET types: Integer is System.Int32, Decimal is System.Decimal, Date is System.DateTime.
  • Underscores in number literals are allowed for readability.
  • Date literals go between # signs and always use the US order #month/day/year#, whatever your computer's regional settings.
  • The c suffix makes a one-character string a Char.

Other numeric types

Short (16-bit), Byte (0–255), Single (32-bit float), and unsigned versions (UInteger, ULong, ...) exist for special cases. Literal suffixes: S (Short), L (Long), F (Single), R (Double), D (Decimal), UI/UL (unsigned).

Value types and reference types

Numbers, Boolean, Char, Date, and structures are value types: the variable holds the value itself. String, arrays, and classes are reference types: the variable holds a reference to an object, and can be Nothing. You'll see why this matters when you meet classes in Level 2.

Common mistakes

  • Using Double for money: 0.1 + 0.2 isn't exactly 0.3. Use Decimal.
  • Writing dates as strings ("09/03/2025") — whether that's March or September depends on regional settings. Use a date literal or New Date(2025, 3, 9).