Hex Function

   
Hex Function

Class

Microsoft.VisualBasic.Conversion

Syntax

 Hex(   number   ) 
number (required; Numeric or String)

A valid numeric or string expression

Return Value

String representing the hexadecimal value of number

Description

Returns a string that represents the hexadecimal value of number

Rules at a Glance

  • If number contains a fractional part, it will be automatically rounded to the nearest whole number before the Hex function is evaluated.

  • number must evaluate to a numeric expression that ranges from -2,147,483,648 to 2,147,483,647. If the argument is outside of this range, runtime error 6, "Overflow," results.

  • The return value of Hex is dependent upon the value and type of number :

number

Return value

Nothing

Zero (0)

Any other number

Up to eight hexadecimal characters

Programming Tips and Gotchas

If the value of number is known beforehand and is not the result of an expression, you can represent the number as a hexadecimal by simply affixing &H to number . Each of the following two statements assigns a hexadecimal value to a variable, for instance:

 lngHexValue1 = &HFF                    ' Assigns 255 lngHexValue2 = "&H" & Len(dblNumber)   ' Assigns 8 

See Also

Oct Function

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net