Dim hexVal As Double, hexVal2 As Double, streetNum As Double
' Assign the hexadecimal value FF (decimal 255).
hexVal# = Val("&HFF")
' Assign the value 106.
streetNum# = Val(" 106 Main St.")
Print hexVal#; streetNum#
' Output:
' 255 106
' Illustrate the need for an ampersand suffix when using large hex values.
' Assign the INCORRECT hexadecimal value 80F0 (decimal 33008).
hexVal# = Val("&H80F0")
' And assign the CORRECT hexadecimal value 80F0 (decimal 33008).
hexVal2# = Val("&H80F0&")
Print hexVal#; hexVal2#
' Output:
' -32528 33008