Search Tools Links Login

VB6 Tutorial 49: Named Constants


The Visual Basic 6 language provides so many built-in constants that save your time and effort for programming.

The Constants start with the "vb" string, for example, vbRed. And you know about the color constants if you’ve read the previous lessons. The named constants are also known as symbolic constants. They have predefined values defined in the VB language.

QuickHint:

You can use the Object Browser to find the full list of named constants available in Visual Basic. Press F2 in the IDE to open the object browser.

This lesson will only cover more commonly used items. However, you'll notice that in the Object Browser, there are many, many more available to help you save time!

Color constants

These constants belong to the "ColorConstants" enumeration. (Search "ColorConstants" in the Object Browser)

These color constants have their long values, for instance, the vbYellow has the long value 65535. It’s hard to remember the numeric values, while the constants are a lot easier, and the code becomes more readable too.

For code examples about color properties, see Common Properties 1 of 3.

Alignment constants

The alignment constants are vbCenter, vbLeftJustify, vbRightJustify.

Button constants

Button constants include vbButtonGraphical, vbButtonStandard that represent graphical and standard appearance of command button respectively.

CheckBox constants

The constants that relate to the CheckBox control are vbChecked, vbUnchecked and vbGrayed constants that are respectively the checked check value, unchecked check value and grayed check value to express the states of the CheckBox control.

Constants from the "Constants" module

FormShow Constants

MouseButton constants

QueryUnload constants

The QueryUnload constants are useful when you take a QueryUnload event in your program. The QueryUnload constants are as follows:

Shift constants

System color constants

There are so many system color constants in VB6. Look up in the Object Browser. (Search "SystemColorConstants")

Only few of them are shown below.

About this post

Posted: 2018-05-22
By: vb6boy
Viewed: 924 times

Categories

Visual Basic 6

VB6 Tutorial

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.