Für einige Datentypen werden in Visual Basic an Variablennamen angehängte Typkennzeichen verwendet:
Currency @
Double #
Integer %
Long &
Single !
String $
Diese Art der Notation entstammt allerdings den älteren Versionen von Visual Basic und sollte deshalb vermieden werden.
Zur Verwendung:
Die Anweisungen Dim Meldung As String und Dim Meldung$ sind identisch, sie deklarieren die Variable Meldung als STRING - Variable.
The initialization_expression assigns the constant its never-changing value. You cannot use variables in the
initialization_expression, but you can use conversion functions such as CInt. You can also use the values
of previously defined constants and enumeration values. The expression can include type characters
such as # or &H, and if the declaration doesn’t include a type statement (and Option Explicit is off),
the type of the value determines the type of the constant.
The following code demonstrates these capabilities. The first statement uses the CInt function to convert
the value 123.45 into an integer constant. The second and third statements set the values of two Long
constants to hexadecimal values. The next statement combines the values defined in the previous two
using a bitwise Or. The final statement sets a constant to a value defined by the enumerated type
AccessLevel.Code: Alles auswählen
Private Const MAX_VALUES As Integer = CInt(123.45) Private Const MASK_READ As Long = &H1000& Private Const MASK_WRITE As Long = &H2000& Private Const MASK_READ_WRITE As Long = MASK_READ Or MASK_WRITE Private Const MAX_ACCESS_LEVEL As AccessLevel = AccessLevel.SuperUs