Basic Constants

Constants used in Basic programs

Boolean constants

Name

Type

Value

True

Boolean

1

False

Boolean

0


Example:


            Dim bPositive as Boolean
            bPositive = True
        

Mathematical constant

Name

Type

Value

Pi

Double

3.14159265358979


Example:


            Function Rad2Deg( aRad as Double) As Double
             Rad2Deg = aRad * 180.00 / Pi
            End Function
        

Object Constants

Name

Type

Usage

Empty

Variant

The Empty value indicates that the variable is not initialized.

Null

null

Indicates that the variable does not contain data.

Nothing

Object

Assign the Nothing object to a variable to remove a previous assignment.


Example:


            SubExampleEmpty
                Dim sVar As Variant
                sVar = Empty
                Print IsEmpty(sVar) ' Returns True
            End Sub
            Sub ExampleNull
                Dim vVar As Variant
                MsgBox IsNull(vVar)
            End Sub
            Sub ExampleNothing
                Dim oDoc As Object
                Set oDoc = ThisComponent
                Print oDoc.Title
                oDoc = Nothing
                Print oDoc ' Error
            End Sub
        

MsgBox Named Constants

рдирд╛рдорд╛рдЩреНрдХрд┐рдд рдЕрдЪрд▓

рдЗрдиреНрдЯрд┐рдЬрд░ рдорд╛рди

рдкрд░рд┐рднрд╛рд╖рд╛

MB_OK

0

'рдареАрдХ рдЫ' рдмрдЯрди рдорд╛рддреНрд░ рдкреНрд░рджрд░реНрд╢рди рдЧрд░реНрдиреБрд╣реЛрд╕реНред

MB_OKCANCEL

1

'рдареАрдХ рдЫ' рд░ 'рд░рджреНрдж рдЧрд░реНрдиреБрд╣реЛрд╕реН' рдмрдЯрдирд╣рд░реВ рдкреНрд░рджрд░реНрд╢рди рдЧрд░реНрдиреБрд╣реЛрд╕реНред

MB_ABORTRETRYIGNORE

2

Display Abort, Retry, and Ignore buttons.

MB_YESNOCANCEL

3

'рд╣реЛ', 'рд╣реЛрдЗрди' рд░ 'рд░рджреНрдж рдЧрд░реНрдиреБрд╣реЛрд╕реН' рдмрдЯрдирд╣рд░реВ рдкреНрд░рджрд░реНрд╢рди рдЧрд░реНрдиреБрд╣реЛрд╕реНред

MB_YESNO

4

'рд╣реЛ' рд░ 'рд╣реЛрдЗрди' рдмрдЯрдирд╣рд░реВ рдкреНрд░рджрд░реНрд╢рди рдЧрд░реНрдиреБрд╣реЛрд╕реНред

MB_RETRYCANCEL

5

'рдкреБрди: рдкреНрд░рдпрд╛рд╕ рдЧрд░реНрдиреБрд╣реЛрд╕реН' рд░ 'рд░рджреНрдж рдЧрд░реНрдиреБрд╣реЛрд╕реН ' рдмрдЯрдирд╣рд░реВ рдкреНрд░рджрд░реНрд╢рди рдЧрд░реНрдиреБрд╣реЛрд╕реНред

MB_ICONSTOP

16

Add the Stop icon to the dialog.

MB_ICONQUESTION

32

рд╕рдВрд╡рд╛рджрдорд╛ рдкреНрд░рд╢реНрди рдкреНрд░рддрд┐рдорд╛ рдердкреНрдиреБрд╣реЛрд╕реНред

MB_ICONEXCLAMATION

48

Add the Exclamation Point icon to the dialog.

MB_ICONINFORMATION

64

рд╕рдВрд╡рд╛рджрдорд╛ рд╕реВрдЪрдирд╛ рдкреНрд░рддрд┐рдорд╛ рдердкреНрдиреБрд╣реЛрд╕реНред

128

рдкреВрд░реНрд╡рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдмрдЯрдирдХреЛ рд░реВрдкрдорд╛ рд╕рдВрд╡рд╛рджрдорд╛ рдкрд╣рд┐рд▓реЛ рдмрдЯрдиред

MB_DEFBUTTON2

256

рдкреВрд░реНрд╡рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдмрдЯрдирдХреЛ рд░реВрдкрдорд╛ рд╕рдВрд╡рд╛рджрдорд╛ рджреЛрд╕реНрд░реЛ рдмрдЯрдиред

MB_DEFBUTTON3

512

рд╕рдВрд╡рд╛рджрдорд╛ рдкреВрд░реНрд╡рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдмрдЯрдирдХреЛ рд░реВрдкрдорд╛ рддреЗрд╕реНрд░реЛ рдмрдЯрдиред


GetAttr Named Constants

Named constant

Value

Definition

ATTR_NORMAL

0

Normal files.

ATTR_READONLY

1

Read-only files.

ATTR_HIDDEN

2

Hidden file

ATTR_SYSTEM

4

System file

ATTR_VOLUME

8

Returns the name of the volume

ATTR_DIRECTORY

16

Returns the name of the directory only.

ATTR_ARCHIVE

32

File was changed since last backup (Archive bit).


VarType Named Constants

Keyword

Named constant

VarType

рдЪрд▓ рдкреНрд░рдХрд╛рд░

Boolean

11

рдмреБрд▓рд┐рдпрди рдЪрд▓

Byte

17

Byte variable

Date

V_DATE

7

рдорд┐рддрд┐ рдЪрд▓

Currency

V_CURRENCY

6

Currency variable

Double

V_DOUBLE

5

рджреНрд╡рд┐-рдЧреБрдирд╛ рдЙрддреНрдкреНрд▓рд╛рд╡рди рдмрд┐рдиреНрджреБ рдЪрд▓

Integer

V_INTEGER

2

рдЗрдиреНрдЯрд┐рдЬрд░ рдЪрд▓

Long

V_LONG

3

рд▓рд╛рдореЛ рдЗрдиреНрдЯрд┐рдЬрд░ рдорд╛рди

Object

9

рд╡рд╕реНрддреБ рдЪрд▓

Single

V_SINGLE

4

рдПрдХрд▓ рдЙрддреНрдкреНрд▓рд╛рд╡рди-рдмрд┐рдиреНрджреБ рдЪрд▓

String

V_STRING

8

рд╕реНрдЯреНрд░рд┐рдЩ рдЪрд▓

Variant

12

рднрд┐рдиреНрди рдЪрд▓(рдкрд░рд┐рднрд╖рд╛рджреНрд╡рд╛рд░рд╛ рдирд┐рд░реНрджрд┐рд╖реНрдЯ рдЧрд░реЗрдХрд╛ рд╕рдмреИ рдкреНрд░рдХрд╛рд░рд╣рд░реВ рд╕рдорд╛рд╡реЗрд╢ рдЧрд░рд╛рдЙрди рд╕рдХрд┐рдиреНрдЫ)рдЪрд▓)

Empty

V_EMPTY

0

рдЪрд▓ рдерд╛рд▓рдирд┐ рднрдПрдХреЛ рдЫреИрди

Null

V_NULL

1

рд╡реИрдз рдбреЗрдЯрд╛ рдЫреИрди


Additional VBA constants

The following constants are available when VBA compatibility mode is enabled

warning

This constant, function or object is enabled with the statement Option VBASupport 1 placed before the executable program code in a module.


VBA Color Named Constants

Named constant

Red, Green, Blue
composition

vbBlack

RGB(0, 0, 0)

vbBlue

RGB(0, 0, 255)

vbCyan

RGB(0, 255, 255)

vbGreen

RGB(0, 255, 0)

vbMagenta

RGB(255, 0, 255)

vbRed

RGB(255, 0, 0)

vbYellow

RGB(255, 255, 0)

vbWhite

RGB(255, 255, 255)


Variable Type Named Constants

Named constant

Decimal value

vbArray

8192

vbBoolean

11

vbByte

17

vbCurrency

6

vbDataObject

13

vbDate

7

vbDecimal

14

vbDouble

5

vbEmpty

0

vbError

10

vbInteger

2

vbLong

3

vbNull

1

vbObject

9

vbSingle

4

vbString

8

vbUserDefinedType

36

vbVariant

12


FormatDateTime VBA Named Constants

Named Constant

Value

Description

vbGeneralDate

0

Displays a date and/or time as defined in your system's General Date setting. If a date only, no time is displayed; If a time only, no date is displayed.

vbLongDate

1

Display a date using the long date format specified in your computer's regional settings.

vbShortDate

2

Display a date using the short date format specified in your computer's regional settings.

vbLongTime

3

Displays a time as defined in your system's Long Time settings.

vbShortTime

4

Display a time using the 24-hour format (hh:mm).


StrConv VBA Named Constants

Conversion

Value

Description

vbUpperCase

1

Converts Text characters to uppercase.

vbLowerCase

2

Converts Text characters lowercase.

vbProperCase

3

Converts the first letter of every word in Text to uppercase.

vbWide

4

Converts narrow (half-width) characters in Text to wide (full-width) characters.

vbNarrow

8

Converts wide (full-width) characters in Text to narrow (half-width) characters.

vbKatakana

16

Converts Hiragana characters in Text to Katakana characters.

vbHiragana

32

Converts Katakana characters in Text to Hiragana characters.

vbUnicode

64

Converts Text characters to Unicode characters using the default code page of the system.

vbFromUnicode

128

Converts Text characters from Unicode to the default code page of the system.


WeekDayName VBA Named Constants

Value

VBA Constant

Description

0

vbUseSystemDayOfWeek

Use system locale settings

1

vbSunday

Sunday (default)

2

vbMonday

Monday

3

vbTuesday

Tuesday

4

vbWednesday

Wednesday

5

vbThursday

Thursday

6

vbFriday

Friday

7

vbSaturday

Saturday


Miscellaneous VBA Named Constants

Named constant

Hexadecimal (decimal) value

Description

vbTrue

-1

Part of vbTriState enumeration.

vbFalse

0

Part of vbTriState enumeration.

vbUseDefault

-2

Part of vbTriState enumeration.

vbCr

\x0D (13)

CR - Carriage return

vbCrLf

\x0D\x0A (13 10)

CRLF - Carriage return and line feed

vbFormFeed

\x0c (12)

FF - Form feed

vbLf

\x0A (10)

LF - Line feed

vbNewLine

\x0D\x0A (13 10) for Windows

\x0A (10) for other systems

LF or CRLF

vbNullString

""

Null string

vbTab

\x09 (9)

HT - Horizontal tab

vbVerticalTab

\x0B (11)

VT - Vertical tab


Please support us!