Constants Declared by Visual Basic

Visual Basic provides a number of predefined constants for developers for use in conditional compilation as well as in printing and displaying data.

Conditional Compilation Constants

The following table lists the predefined constants available for conditional compilation.

Constant

Description

CONFIG

A string that corresponds to the current setting of the Active Solution Configuration box in the Configuration Manager.

DEBUG

A Boolean value that can be set in the Project Properties dialog box. By default, the Debug configuration for a project defines DEBUG. When DEBUG is defined, Debug class methods generate output to the Output window. When it is not defined, Debug class methods are not compiled and no Debug output is generated.

TARGET

A string representing the output type for the project or the setting of the command-line /target option. The possible values of TARGET are:

  • "winexe" for a Windows application.

  • "exe" for a console application.

  • "library" for a class library.

  • "module" for a module.

  • The /target option may be set in the Visual Studio integrated development environment. For more information, see /target (Visual Basic).

TRACE

A Boolean value that can be set in the Project Properties dialog box. By default, all configurations for a project define TRACE. When TRACE is defined, Trace class methods generate output to the Output window. When it is not defined, Trace class methods are not compiled and no Trace output is generated.

VBC_VER

A number representing the Visual Basic version, in major.minor format. The version number for Visual Basic 2005 is 8.0.

When you call print and display functions, you can use the following constants in your code in place of the actual values.

Constant

Description

vbCrLf

Carriage return/linefeed character combination.

vbCr

Carriage return character.

vbLf

Linefeed character.

vbNewLine

Newline character.

vbNullChar

Character having a value of 0.

vbNullString

Not the same as a zero-length string (""); used for calling external procedures.

vbObjectError

Error number. User-defined error numbers should be greater than this value. For example:

Err.Raise(Number) = vbObjectError + 1000

vbTab

Tab character.

vbBack

Backspace character.

vbFormFeed

Not used in Microsoft Windows.

vbVerticalTab

Not useful in Microsoft Windows.

See Also

Tasks

How to: Declare A Constant

Concepts

Enumerations Declared by Visual Basic

Constants Overview

User-Defined Constants

Constant and Literal Data Types