Basic-Konstanten

Konstanten, die in Basic-Programmen verwendet werden

Boole'sche Konstanten

Name

Typ

Wert

True

Boolean

1

False

Boolean

0


Beispiel:

Dim bPositive as Boolean

bPositive = True

Mathematische Konstante

Name

Typ

Wert

Pi

Double

3.14159265358979


Beispiel:

Function Rad2Deg( aRad as Double) As Double

 Rad2Deg = aRad * 180.00 / Pi

End Function

Objektkonstanten

Name

Typ

Verwendung

Empty

Variant

Der Wert Empty zeigt an, dass die Variable noch nicht initialisiert wurde.

Null

null

Zeigt an, dass die Variable keine Daten enthält.

Nothing

Object

Weist einer Variablen das Objekt Nothing zu, um eine vorherige Zuweisung zu entfernen.


Beispiel:

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

Zusätzliche VBA-Konstanten

Die folgenden Konstanten sind verfügbar, wenn der VBA-Kompatibilitätsmodus aktiviert ist

Warnsymbol

Diese Funktion oder Konstante ist aktiviert, wenn die Anweisung Option VBASupport 1 vor dem ausführbaren Programmcode in einem Modul platziert wurde.


Benannte Konstante

Hexadezimal-Wert (Dezimal)

Beschreibung

vbCr

\x0D (13)

CR - Wagenrücklauf

vbCrLf

\x0D\x0A (13 10)

CRLF - Wagenrücklauf und Zeilenvorschub

vbFormFeed

\x0c (12)

FF - Seitenvorschub

vbLf

\x0A (10)

LF - Zeilenvorschub

vbNewLine

\x0D\x0A (13 10) für Windows mit 32 Bit

\x0A (10) für andere 64-Bit-Systeme

LF oder CRLF

vbNullString

""

Nullzeichen

vbTab

\x09 (9)

HT - Horizontaler Tabulator

vbVerticalTab

\x0B (11)

VT - Vertikaler Tabulator