Beruflich Dokumente
Kultur Dokumente
In addition to specifying a data type in a declaration statement, you can force the data type of some programming elements with a type character. The type character must immediately follow the element, with no intervening characters of any kind. The type character is not part of the name of the element. An element defined with a type character can be referenced without the type character.
Data type
Integer Long Decimal Single Double String
Example
Dim L% Dim M& Const W@ = 37.5 Dim Q! Dim X# Dim V$ = "Secret"
No identifier type characters exist for the Boolean, Byte, Char, Date, Object, SByte, Short, UInteger, ULong, or UShort data types, or for any composite data types such as arrays or structures. In some cases, you can append the $ character to a Visual Basic function, for example Left$ instead of Left, to obtain a returned value of type String. In all cases, the identifier type character must immediately follow the identifier name.
Textual form of literal Numeric, no fractional part Numeric, no fractional part, too large for Integer Numeric, fractional part Enclosed within double quotation marks Enclosed within number signs
Data type
Short Integer Long Decimal Single Double UShort UInteger ULong Char
Example
I J K X Y Z L M N Q = = = = = = = = = = 347S 347I 347L 347D 347F 347R 347US 347UI 347UL "."C
No literal type characters exist for the Boolean, Byte, Date, Object, SByte, or String data types, or for any composite data types such as arrays or structures. Literals can also use the identifier type characters (%, &, @, !, #, $), as can variables, constants, and expressions. However, the literal type characters (S, I, L, D, F, R, C) can be used only with literals. In all cases, the literal type character must immediately follow the literal value.
Number base
Hexadecimal (base 16) Octal (base 10)
Prefix
&H &O
Example
&HFFFF &O77
You can follow a prefixed literal with a literal type character. The following example shows this.