Q(uick)BASIC Function: HEX$

Quick View

HEX$

A string function that returns a string that represents the hexadecimal value of the decimal argument expression

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • HEX$(numeric-expression&)
  • OCT$(numeric-expression&)
Description/Parameter(s)
numeric-expression& Any numeric expression. The expression is rounded to an integer or long integer before it is evaluated.
Example
INPUT x a$ = HEX$ (x) b$ = OCT$ (x) PRINT x; "decimal is "; a$; " hexadecimal and "; b$; " in octal."
Syntax
  • HEX$(expression)
Description/Parameter(s)

The argument expression is rounded to an integer or, if the expression is outside the integer range, a long integer before the HEX$ function evaluates it.

Example

This example displays the hexadecimal value of a decimal number you supply.

CLS ' Clear screen INPUT X A$ = HEX$(X) PRINT X; "decimal is "; A$; " hexadecimal"

Sample Output:

? 32 32 decimal is 20 hexadecimal

See also:

Syntax
  • HEX$(numeric-expression&)
Description/Parameter(s)
  • The numeric-expression& is rounded to an integer or, if the expression is outside the integer range, a long integer, before the HEX$ function evaluates it.
Example

This example uses the HEX$ function to display the hexadecimal value of a decimal number you supply.

CLS 'Clear screen. INPUT X A$ = HEX$(X) PRINT X; "decimal is "; A$; " hexadecimal"

Sample Output:

? 32 32 decimal is 20 hexadecimal

See also: