Excel VBA extract from big Hex number

MyKoiFish 1 Reputation point
2022-07-29T09:17:28.327+00:00

I am looking for solution.

I am working on testing a hardware and it gives me data in big 40 char long hex number which is actually 10 word like "0001FC000002FF000001FF0001C2FF000025FF03"

my goal is separate the 4 digits from this number and put it in right word like my Word0 = 0001 and Word1 = FC00

GetChar, substring, I was tying but not recognised by excel VBA.

How to access each bit or any other way to separate the nibble of long number

Developer technologies | Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2022-07-29T09:39:48.837+00:00

    Try one of solutions:

    Dim t As String  
      
    t = "0001FC000002FF000001FF0001C2FF000025FF03"  
      
    Dim numbers(9) As Integer  
      
    Dim i As Integer  
    For i = 0 To 9  
      
        numbers(i) = Val("&H" & Mid(t, i * 4 + 1, 4))  
      
    Next i  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.