Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Return a string that is the hexadecimal (base 16) representation of its argument.

 

Syntax

 

s = HEX$(Number [, digits])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

Number

Numeric

No

The numeric expression to transform into hex notation

Digits

Numeric

Yes

Number of digits to output

 

Remarks

 

Restrictions

 

See also

 

String Handling,

 

Examples

 

Thanks to Abraxas for the following script example

' Usage of the HEX$ Instruction example

' Returns HEX String of a number

 

Dim Base10Num As DWORD VALUE &hAAAA5555

Dim TempVal   As DWORD VALUE Base10Num

Dim n         As Byte  VALUE 0

Dim sMsg      As String

 

sMsg += "Base10 = " & Base10Num & $CRLF 

sMsg += "Binary = " & Bin$(Base10Num, 32) & $CRLF

sMsg += "Hex Nibbles = "

 

' This Groups 4 bits (a nibble) 

For n = 28 To 0 Step -4

  TempVal = Base10Num

  sMsg += " " & HEX$((SHIFT SIGNED RIGHT TempVal, n), 1) ' Shift(n) bits

Next

 

sMsg += $CRLF

sMsg += "Hex = &h" & Hex$(Base10Num, 8)

MSGBOX 0, sMsg ' Display The information

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software