SoFunction
Updated on 2025-03-10

Page 1/2 of the constants to be used in VBA

Calendar constant

The following can be used anywhere in the codeconstantInstead of actual values:

constant value describe
vbCalGreg 0 It is pointed out that the use of the solar calendar.
vbCalHijri 1 It is pointed out that the Islamic calendar is used.

Color Constant

The following can be used anywhere in the codeconstantInstead of actual values:

constant value describe
vbBlack 0x0 black
vbRed 0xFF red
vbGreen 0xFF00 green
vbYellow 0xFFFF yellow
vbBlue 0xFF0000 blue
vbMagenta 0xFF00FF Purple red
vbCyan 0xFFFF00 blue
vbWhite 0xFFFFFF White

CallType constant

The following can be used anywhere in the codeconstantInstead of actual values:

constant value describe
vbMethod 1 Specifies that a method has been called.
vbGet 2 Point oneProperty Getprocess.
vbLet 4 Point oneProperty Let process.
vbSet 8 Point oneProperty Setprocess.
the followingconstantBy Visual Basic for ApplicationsType libraryDefinition, which can be used to replace the actual value anywhere in the code:

Comparison constant

constant value describe
VbUseCompareOption -1 Use the settings of the Option Compare statement for comparison.
VbBinaryCompare 0 Make binary comparisons.
VbTextCompare 1 Make a text comparison.
vbDatabaseCompare 2 For Microsoft Access (Windows only), perform comparisons based on the information contained in the database.

Compiler constant

Visual Basic for Applications defines some things that cannot be used with #If...Then...#Else Used together with instructionsconstant. These constants are in addition to theirscopeis global; that is, except forprojectApply everywhere in function with #If...Then...#Else The constants defined by the instruction are the same.

On a 16-bit development platform, the compilation constant is defined as follows:

constant value describe
Win16 True It points out that the development environment is 16 bits.
Win32 False Point out that the development environment is not 32 bit.

On a 32-bit development platform, the compilation constant is defined as follows:

constant value describe
Vba6 True It points out that the development environment is Visual Basic for Applications, version 6.0.
Vba6 False It points out that the development environment is not Visual Basic for Applications, version 6.0.
Win16 False Point out that the development environment is not 16 bit.
Win32 True It points out that the development environment is 32 bit.

Mac False Point out that the development environment is not Macintosh.
Win16 False It points out that the development environment is not 16-bit.
Win32 False It points out that the development environment is not 32-bit.
Mac True It points out that the development environment is Macintosh.

NoticeThese constants are provided by Visual Basic, so you cannot define your own constants with the same name in any level.

 

Date constant

The following can be used anywhere in the codeconstantInstead of actual values:

Parameter value

firstdayofweek parameterHave the following values:

constant value describe
vbUseSystem 0 Use the NLS API settings.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

firstdayofyear The parameters have the following values:

constant value describe
vbUseSystem 0 Use the NLS API settings.
VbUseSystemDayOfWeek 0 Use the number of weeks specified for the first day of the week in the system settings.
VbFirstJan1 1 Starting from the week on January 1st (default).
vbFirstFourDays 2 Starting from the first week of the new year with at least 4 days.
vbFirstFullWeek 3 Starting from the first full week of the year.

Return value

constant value describe
vbSunday 1 Sunday
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

Date format constant

Only if your project's corresponding pairs containing these constant definitionsType libraryThese constants can only be used when there is an explicit reference.

constant value describe
vbGeneralDate 0 Shows date and/or time. For a real number, the date and time are displayed. If there is no decimal part, only the date is displayed. If there is no integer part, only the time is displayed. The display of date and time is determined by the system setting values.
vbLongDate 1 Displays dates in the long date format specified by the computer locale value.
vbShortDate 2 Displays dates in the short date format specified by the computer locale value.
vbLongTime 3 Display time with the long-term format specified by the computer area setting value.
vbShortTime 4 Display time with the short-time format specified by the computer area setting value.

Dir, GetAttr, and SetAttr constants

The following can be used anywhere in the codeconstantInstead of actual values:

constant value describe
vbNormal 0 Normal (Dir andSetAttrDefault value)
vbReadOnly 1 Read-only
vbHidden 2 Hidden
vbSystem 4 System files
vbVolume 8 Coil label
vbDirectory 16 Directory or folder
vbArchive 32 The file has changed since the last backup
vbAlias 64 On Macintosh, the identifier is an alias.

On Macintosh, onlyVbNormalvbReadOnly、 vbHiddenandvbAliasis available.

12Next pageRead the full text