Konstante v Basicu
Konstante, uporabljene v programski kodi Basic
Logične konstante
Ime |
Vrsta |
Vrednost |
True |
Boolean |
1 |
False |
Boolean |
0 |
Dim bPositive as Boolean
bPositive = True
Matematična konstanta
Ime |
Vrsta |
Vrednost |
Pi |
Double |
3.14159265358979 |
Function Rad2Deg( aRad as Double) As Double
Rad2Deg = aRad * 180.00 / Pi
End Function
Konstante predmetov
Ime |
Vrsta |
Raba |
Empty |
Variant |
Vrednost Empty pomeni, da spremenljivka še ni bila inicializirana. |
Null |
null |
Označuje, da spremenljivka ne vsebuje podatkov. |
Nothing |
Object |
Spremenljivki priredite predmet Nothing, če želite odstraniti predhodno prireditev. |
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
Dodatne konstante VBA
Naslednje konstante so na voljo, če je omogočen združljivostni način VBA:
Poimenovana konstanta |
Šestnajstiška (desetiška) vrednost |
Opis |
vbCr |
\x0D (13) |
CR – prehod na začetek vrstice (angl. carriage return) |
vbCrLf |
\x0D\x0A (13 10) |
CRLF – prehod na začetek vrstice in pomik v novo vrsto |
vbFormFeed |
\x0c (12) |
FF – pomik na novo stran (angl. form feed) |
vbLf |
\x0A (10) |
LF – pomik v novo vrsto (angl. line feed) |
vbNewLine |
\x0D\x0A (13 10) v 32-bitnih sistemih Windows \x0A (10) v drugih 64-bitnih sistemih |
LF ali CRLF |
vbNullString |
"" |
Ničelni niz |
vbTab |
\x09 (9) |
HT – vodoravni tabulator (angl. horizontal tab) |
vbVerticalTab |
\x0B (11) |
VT – navpični tabulator (angl. vertical tab) |