Basic Constants

Constants utilitzades als programes Basic

Constants booleanes

Nom

Tipus

Valor

True

Boolean

1

False

Boolean

0


Exemple:


            Dim bPositive as Boolean
            bPositive = True
        

Constant matemàtica

Nom

Tipus

Valor

Pi

Double

3.14159265358979


Exemple:


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

Constants d'objecte

Nom

Tipus

Utilització

Empty

Variant

El valor Buit indica que la variable no s'ha inicialitzat.

Null

null

Indica que la variable no conté cap dada.

Nothing

Object

Assigneu l'objecte Res a una variable per suprimir una assignació anterior.


Exemple:


            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

Constant amb nom

Valor enter

Definició

MB_OK

0

Mostra només el botó «D'acord».

MB_OKCANCEL

1

Mostra els botons «D'acord» i «Cancel·la».

MB_ABORTRETRYIGNORE

2

Mostra els botons «Avorta», «Reintenta« i «Ignora».

MB_YESNOCANCEL

3

Mostra els botons «Sí», «No» i «Cancel·la».

MB_YESNO

4

Mostra els botons «Sí» i «No».

MB_RETRYCANCEL

5

Mostra els botons «Reintenta» i «Cancel·la».

MB_ICONSTOP

16

Afegeix la icona de «Stop» al diàleg.

MB_ICONQUESTION

32

Afegeix la icona de pregunta al diàleg.

MB_ICONEXCLAMATION

48

Afegeix la icona d'exclamació al diàleg.

MB_ICONINFORMATION

64

Afegeix la icona d'informació al diàleg.

128

Estableix el primer botó del diàleg com a botó per defecte.

MB_DEFBUTTON2

256

Estableix el segon botó del diàleg com a botó per defecte.

MB_DEFBUTTON3

512

Estableix el tercer botó del diàleg com a botó per defecte.


GetAttr Named Constants

Constant amb nom

Valor

Definició

ATTR_NORMAL

0

Fitxers normals.

ATTR_READONLY

1

Fitxers de només de lectura.

ATTR_HIDDEN

2

Fitxer amagat

ATTR_SYSTEM

4

Fitxer del sistema

ATTR_VOLUME

8

Retorna el nom del volum

ATTR_DIRECTORY

16

Retorna només el nom del directori.

ATTR_ARCHIVE

32

El fitxer s'ha canviat des de l'última còpia de seguretat (bit d'arxivament).


Constants amb nom dels tipus de dades

Valors per a
TypeName

Constant
amb nom

VarType
values

Tipus de variable

…()

8192

Array of variables

Boolean

11

Boolean variable

Byte

17

Byte variable

Date

V_DATE

7

Date variable

Currency

V_CURRENCY

6

Currency variable

Double

V_DOUBLE

5

Double-precision floating-point variable

Error

11

Error type variable

Integer

V_INTEGER

2

Integer variable

Long

V_LONG

3

Long integer variable

Object

9

Object variable

Single

V_SINGLE

4

Single-precision floating-point variable

String

V_STRING

8

String variable

Variant

12

Variant variable (can contain all types specified by the definition)

Empty

V_EMPTY

0

Uninitialized Variant variable

Null

V_NULL

1

No hi ha dades vàlides


Constants addicionals del VBA

Les constants següents estan disponibles quan s'activa el mode de compatibilitat VBA

warning

Aquesta constant, funció o objecte s'activa mitjançant l'expressió Option VBASupport 1, col·locada abans del codi executable del programa en un mòdul.


VBA Color Named Constants

Constant amb nom

Composició de
vermell, verd i blau

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

Constant amb nom

Valor decimal

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

Constant amb nom

Valor

Descripció

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

Mostra l'hora utilitzant el format de 24 hores (hh:mm).


StrConv VBA Named Constants

Conversió

Valor

Descripció

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

Valor

VBA Constant

Descripció

0

vbUseSystemDayOfWeek

Use system locale settings

1

vbSunday

Diumenge (per defecte)

2

vbMonday

Dilluns

3

vbTuesday

Dimarts

4

vbWednesday

Dimecres

5

vbThursday

Dijous

6

vbFriday

Divendres

7

vbSaturday

Dissabte


Miscellaneous VBA Named Constants

Constant amb nom

Valor hexadecimal (decimal)

Descripció

vbTrue

-1

Part de l'enumeració vbTriState.

vbFalse

0

Part de l'enumeració vbTriState.

vbUseDefault

-2

Part de l'enumeració vbTriState.

vbCr

\x0D (13)

CR - retorn de carro

vbCrLf

\x0D\x0A (13 10)

CRLF - retorn de carro i avançament de línia

vbFormFeed

\x0c (12)

FF - salt de pàgina

vbLf

\x0A (10)

LF - avançament de línia

vbNewLine

\x0D\x0A (13 10) for Windows

\x0A (10) for other systems

LF o CRLF

vbNullString

""

Cadena nul·la

vbTab

\x09 (9)

HT - tabulació horitzontal

vbVerticalTab

\x0B (11)

VT - tabulació vertical


Ens cal la vostra ajuda!