By default, every value with a fractional part is treated as a Double value because this type can accommodate fractional values with the greatest possible accuracy. Assigning a Double value to a Decimal variable will produce an error if the Strict option is on, so you must specify explicitly that the two values should be converted to the Decimal type. The D character at the end of the value is called a type character. Following Table lists all of the type characters that are available in Visual Basic.
Type Character | Description | Example |
---|---|---|
C | Converts value to a Char type | Dim ch As String = "A"c |
D or @ | Converts value to a Decimal type | Dim price As Decimal = 12.99D |
R or # | Converts value to a Double type | Dim pi As Double = 3.14R |
I or % | Converts value to an Integer type | Dim count As Integer = 99I |
L or & | Converts value to a Long type | Dim distance As Long = 1999L |
S | Converts value to a Short type | Dim age As Short = 1S |
F or ! | Converts value to a Single type | Dim velocity As Single = 74.99F |