Name

Const Statement

Synopsis

[accessmodifier] Const constantname [As type] = constantvalue
accessmodifier optional; Keyword

One of the keywords Public, Private, Protected, Friend, or Protected Friend.

constantname required; String Literal

The name of the constant.

type optional; Keyword

The data type; it can be Byte, Boolean, Char, Short, Integer, Long, Single, Double, Decimal, Date, or String, as well as any of the data types defined in the Base Class Library.

constantvalue required; Numeric or String

A literal, constant, or any combination of literals and constants that includes arithmetic or logical operators, except Is.

Description

Associates a constant value with a name. This feature is provided to make code more readable. The name is referred to as a symbolic constant.

If Option Strict is on, the data type of the constant must be defined by using the As type clause.

Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.