Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to convert Hex -> Dec -> Char

How to convert Hex -> Dec -> Char

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pallaka
    wrote on last edited by
    #1

    I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @

    C D L 3 Replies Last reply
    0
    • P pallaka

      I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can use an overload of the ToString method to specify the number format to show.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • P pallaka

        I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @

        D Offline
        D Offline
        DaveAuld
        wrote on last edited by
        #3

        Look up Byte Coversions in the MSDN index, you will see the following example;

        Dim MyString As String = "Encoding String."
        Dim AE As New ASCIIEncoding()
        Dim ByteArray As Byte() = AE.GetBytes(MyString)
        Dim x as Integer
        For x = 0 To ByteArray.Length - 1
        Console.Write("{0} ", ByteArray(x))
        Next

        That should get you started.

        Dave Who am I?: Web|Facebook|Twitter|LinkedIn|Bebo

        1 Reply Last reply
        0
        • P pallaka

          I need to convert data from hex to Dec and dec to Char Kindly let me know how can i do that. The confusion is if i need to change the data If i provide Input as a string to the text box 3F 50 52 40 -> 63 80 82 64 -> ? P R @

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, your question isn't clear. Maybe what you want is: "I have a string with hex byte values, and I want to convert it to a string holding the ASCII-equivalent characters". If so, you need: - a way to split the input string in substrings that each represent a single byte (e.g. use string.split to split on spaces) - a loop to iterate over each substring - byte.TryParse(...,NumberStyles.Hexadecimal) to convert this to a byte array - Encoding.ASCII.GetString to convert to the result - optionally insert spaces to separate the characters :)

          Luc Pattyn


          I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups