Page 1/2 of constants used in VBA

Source: Internet
Author: User
Document directory
  • Parameter Value
  • Return Value

Calendar constant

You can replace the actual value with the following constant anywhere in the Code:

Constant Value Description
VbCalGreg 0 Indicates that the Gregorian calendar is used.
VbCalHijri 1 It indicates that the Islamic calendar is used.
Color constant

You can replace the actual value with the following constant anywhere in the Code:

Constant Value Description
VbBlack 0x0 Black
VbRed 0xFF Red
VbGreen 0xFF00 Green
VbYellow 0 xFFFF Yellow
VbBlue 0xFF0000 Blue
VbMagenta 0xFF00FF Purple red
VbCyan 0xFFFF00 Cyan
VbWhite 0 xFFFFFF White

CallType constant

You can replace the actual value with the following constant anywhere in the Code:

Constant Value Description
VbMethod 1 Indicates that a method has been called.
VbGet 2 SpecifyProperty GetProcess.
VbLet 4 SpecifyProperty LetProcess.
VbSet 8 SpecifyProperty SetProcess.

The following constants are defined by the Type Library in Visual Basic for Applications and can be used to replace the actual values anywhere in the Code:
Comparison constant

Constant Value Description
VbUseCompareOption -1 Use the Option Compare statement settings for comparison.
VbBinaryCompare 0 For binary comparison.
VbTextCompare 1 Compare the text.
VbDatabaseCompare 2 Microsoft Access (Windows only) is used to compare the information contained in the database.
Compiler constant

Visual Basic for Applications defines# If... Then... # ElseThe constant used by the command. In addition to its range, these constants are global. That is to say, apart from being applied everywhere in the project# If... Then... # ElseThe constants defined by the command are the same.

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

Constant Value Description
Win16 True It indicates that the development environment is 16 bits.
Win32 False It indicates that the development environment is not 32-bit.

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

Constant Value Description
Vba6 True The development environment is Visual Basic for Applications, version 6.0.
Vba6 False It indicates that the development environment is not Visual Basic for Applications, version 6.0.
Win16 False It indicates that the development environment is not 16 bits.
Win32 True It indicates that the development environment is 32 bits.

Mac False It indicates that the development environment is not a Macintosh.
Win16 False It indicates that the development environment is not 16 bits.
Win32 False It indicates that the development environment is not 32-bit.
Mac True Indicates that the development environment is Macintosh.

Note:These constants are provided by Visual Basic, so they cannot be defined with the same name in any hierarchy.

Date constant

You can replace the actual value with the following constant anywhere in the Code:

Parameter Value

FirstdayofweekParameters have the following values:

Constant Value Description
VbUseSystem 0 Use 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

FirstdayofyearParameters have the following values:

Constant Value Description
VbUseSystem 0 Use nls api settings.
VbUseSystemDayOfWeek 0 Use the number of weeks specified for the first day of the week in the system settings.
VbFirstJan1 1 It starts from the week where January 1, January 1 (default ).
VbFirstFourDays 2 The week starts with the first four days of the year.
VbFirstFullWeek 3 It starts with the first complete week of the year.

Return Value

Constant Value Description
VbSunday 1 Sunday
VbMonday 2 Monday
VbTuesday 3 Tuesday
VbWednesday 4 Wednesday
VbThursday 5 Thursday
VbFriday 6 Friday
VbSaturday 7 Saturday

Date Format constant

These constants can be used only when your project has an explicit reference to the corresponding type library containing these constant definitions.

Constant Value Description
VbGeneralDate 0 Displays the 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, only the time is displayed. The display of date and time is determined by the system setting value.
VbLongDate 1 Display the date in the long date format specified by the computer region setting value.
Vb1_date 2 Display the date in the short date format specified by the computer region setting value.
VbLongTime 3 Set the display time in the long time format specified by the computer region value.
Vb1_time 4 Set the display time in the short time format specified by the computer region value.
Dir, GetAttr, and SetAttr Constants

You can replace the actual value with the following constant anywhere in the Code:

Constant Value Description
VbNormal 0 Normal (DirAndSetAttr)
VbReadOnly 1 Read-Only
VbHidden 2 Hidden
VbSystem 4 System Files
VbVolume 8 Scale
VbDirectory 16 Directory or folder
VbArchive 32 The file has changed since the last backup
VbAlias 64 On a Macintosh, an identifier is an alias.

On the Macintosh, onlyVbNormal,VbReadOnly, VbHiddenAndVbAliasIs available.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.