CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2011
    Posts
    9

    [RESOLVED] Convert String representation of HEX to HEX value

    Hi,

    I've been looking all over, but i cant seem to find an answer to this..
    If i have this code for example:

    String myHex = "0x1E";


    Is it possible to convert that string to the actual HEX value -> 0x1E?
    I don't know if i'm clear enough.

    Thanks in advance.

  2. #2
    Join Date
    May 2005
    Location
    San Antonio Tx
    Posts
    44

    Re: Convert String representation of HEX to HEX value

    Do you mean convert from a string that has a hex value to let say an int that has that hex value so you can make calculations with it?

    you can do that with parseInt from the Integer class:
    Code:
    String myHex = "1E";
    int hexVal = Integer.parseInt(myHex, 16);

  3. #3
    Join Date
    Oct 2011
    Posts
    9

    Re: Convert String representation of HEX to HEX value

    Yes that's it! Thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured