Convert Hex number to text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • subedimite
    New Member
    • Apr 2010
    • 21

    #1

    Convert Hex number to text

    Here I am with another question being a very new VBA user.


    I have this scenario to work with: I would think this is fairly common routine of work for VBA.
    I have a string of hex contents as characters such as

    String1 = “3B F0 96 00 FF C0 0A 31 FE 4D D1”

    I need to do some calculation with these and then update a table with the text value. For example, A sum of all these.

    Hence my first steps would be

    1. Convert the whole string to number one by one in a loop.
    2. Do the calculation (Add all the numbers)
    3. Convert the total value( number) into Hex with the Hex function.
    4. Convet the Hex value back to text, i.e if it 9F, then convert to 9F text
    5. Update the table with the 9F.

    I found a function to convert string to number and then to Hex and hence I think I can handle all the steps apart from step 4.

    Could you please let me know if there is any function available that will convert Hex number to text or string.
  • subedimite
    New Member
    • Apr 2010
    • 21

    #2
    According to the other thread all I need to do is this

    Debug.Print Hex$(Val(&HHexV alue))

    So it should all be fine:


    Cheers:

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      The function Hex() is actually all you need. It will take values expressed as ordinary decimal just as well as hex values. Debug.Print is simply the part that displays the value for you to check it. It is not really part of the solution as such.

      Comment

      • subedimite
        New Member
        • Apr 2010
        • 21

        #4
        Hi Thanks for that , although became pretty later to thank it:). It is all fine for me:)

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          No worries. Glad you're sorted :)

          Comment

          Working...