While Matt's method will work, it is rather inefficient to convert the integer to a hexadecimal string, reverse the order of the characters in the string, and then parse it back into an integer again. If efficiency is important, and you only need to reverse the nibbles in a two-byte integer, then the following will work:
Public Function ReverseHexDigits(input As Integer) As Integer
Return ((input And &HF) << 12) Or
((input And &HF0) << 4) Or
((input And &HF00) >> 4) Or
((input And &HF000) >> 12)
End Function
However, that's confusing, since it only operates on the lower two-bytes. It would be more clear if it operated on UShort
variables instead:
Public Function ReverseHexDigits(input As UShort) As UShort
Return ((input And CUShort(&HF)) << 12) Or
((input And CUShort(&HF0)) << 4) Or
((input And CUShort(&HF00)) >> 4) Or
((input And CUShort(&HF000)) >> 12)
End Function