Costanti di Basic
Constanti usate nei programmi Basic
Costanti logiche (booleane)
Nome |
Tipo |
Valore |
True |
Boolean |
1 |
False |
Boolean |
0 |
Dim bPositive as Boolean
bPositive = True
Costanti matematiche
Nome |
Tipo |
Valore |
Pi |
Double |
3.14159265358979 |
Function Rad2Deg( aRad as Double) As Double
Rad2Deg = aRad * 180.00 / Pi
End Function
Costanti di oggetti
Nome |
Tipo |
Uso |
Empty |
Variant |
Il valore Empty indica che la variabile non è inizializzata. |
Null |
null |
Indica che la variabile non contiene dati. |
Nothing |
Object |
Assegna l'oggetto Nothing a una variabile per rimuovere l'assegnazione precedente. |
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
Costanti VBA aggiuntive
Quando è attivato il modo compatibilità VBA sono disponibili le seguenti costanti
Costante con nome |
Valore (decimale) esadecimale |
Descrizione |
vbCr |
\x0D (13) |
CR - Carriage return (ritorno a capo) |
vbCrLf |
\x0D\x0A (13 10) |
CRLF - Carriage return and line feed (ritorno a capo e nuova riga) |
vbFormFeed |
\x0c (12) |
FF - Form feed (salto di pagina) |
vbLf |
\x0A (10) |
LF - Line feed (nuova riga) |
vbNewLine |
\x0D\x0A (13 10) per Windows a 32 bit \x0A (10) per altri sistemi a 64 bit |
LF o CRLF |
vbNullString |
"" |
Stringa Null |
vbTab |
\x09 (9) |
HT - Tabulazione orizzontale |
vbVerticalTab |
\x0B (11) |
VT - Tabulazione verticale |