Variables

VB does not require that variables be declared before they are used unless Option Explicit is On (its default value). In that case, you can declare variables using the Dim, Public, Private, Protected, Friend, or Protected Friend statements.

A variable name in VB must satisfy the following requirements:

  • It must be 16,383 or fewer characters in length.

  • It must begin with an alphabetic character or an underscore.

  • It cannot include embedded spaces.

  • It cannot contain any special (i.e., non-alphabetic, non-numeric) character other than an underscore.

  • It must be unique within its scope.

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.