rdrjr
New Member
- Joined
- Sep 28, 2019
- Messages
- 32
- Office Version
- 365
- Platform
- Windows
Okay this is what I am trying to do. I need to take a Hex value and have it returned in reverse Byte pairs as in the following diagram
For instance the top line (480000074B26E42D) being the original hex value, then reversing it so that the outcome = 2D E4 26 48 07 00 00 48
I have tried using the following code however the result I get is not what I am needing. It starts out fine but gets all jumbled up somewhere in the middle. As a most welcomed plus it also should be able to run as small as 1 Hex pair to as large as 16 hex pair. And would be even more beneficial if it could also find the hex value from a value such as value 1000 = hex value E8 03 taking note that the E8 03 value is already reversed as the original would have been 3E8 or 03E8
Public Function Hex_Pairs_Rev(ByVal strValue As String) As String
Dim lngLoop As Long
Dim strReturn As String
strReturn = ""
For lngLoop = Len(strValue) - 1& To 1& Step -2&
strReturn = strReturn & Mid$(strValue, lngLoop, 2)
Next lngLoop
Hex_Pairs_Rev = strReturn
End Function
For instance the top line (480000074B26E42D) being the original hex value, then reversing it so that the outcome = 2D E4 26 48 07 00 00 48
I have tried using the following code however the result I get is not what I am needing. It starts out fine but gets all jumbled up somewhere in the middle. As a most welcomed plus it also should be able to run as small as 1 Hex pair to as large as 16 hex pair. And would be even more beneficial if it could also find the hex value from a value such as value 1000 = hex value E8 03 taking note that the E8 03 value is already reversed as the original would have been 3E8 or 03E8
Public Function Hex_Pairs_Rev(ByVal strValue As String) As String
Dim lngLoop As Long
Dim strReturn As String
strReturn = ""
For lngLoop = Len(strValue) - 1& To 1& Step -2&
strReturn = strReturn & Mid$(strValue, lngLoop, 2)
Next lngLoop
Hex_Pairs_Rev = strReturn
End Function