PDA

View Full Version : Usage of the HEX$ Keyword



Michael Clease
28-05-2007, 00:20
Could use this or the BIN$ Version about the same.



' Usage of the HEX$ Instruction example
'
' Returns HEX String of a number
'
' Written by Abraxas

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

ErosOlmi
28-05-2007, 07:39
Added. Thanks