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 store a string in Byte array in hex form

How to store a string in Byte array in hex form

Scheduled Pinned Locked Moved Visual Basic
data-structureshelptutorialquestion
2 Posts 2 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.
  • J Offline
    J Offline
    jainiraj
    wrote on last edited by
    #1

    I want store a string in byte array in hex format.How can I do this. Actually I want to store an IP address like 165.8.98.76 in byte array. I am using Hex() method to convert each no. like changing 165 to its hex no. Then chnage 8 to 8. and so on. But Now how can i store this in byte array. Problem- When I convert a no. to hex.Suppose 35 in decimal to 23 in hex. and when i use BIp = StrConv(strIp, vbFromUnicode) Then it stores each digit in 1 byte. Suppose 172= AC in hex the above method store 'A' in 1 byte and 'C' in 2 byte. How can I store IP Address in Byte array. Thanks in adv.

    D 1 Reply Last reply
    0
    • J jainiraj

      I want store a string in byte array in hex format.How can I do this. Actually I want to store an IP address like 165.8.98.76 in byte array. I am using Hex() method to convert each no. like changing 165 to its hex no. Then chnage 8 to 8. and so on. But Now how can i store this in byte array. Problem- When I convert a no. to hex.Suppose 35 in decimal to 23 in hex. and when i use BIp = StrConv(strIp, vbFromUnicode) Then it stores each digit in 1 byte. Suppose 172= AC in hex the above method store 'A' in 1 byte and 'C' in 2 byte. How can I store IP Address in Byte array. Thanks in adv.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You definiately do not screw around with the Hex function to do this. Have you seen the System.Net.IpAddress class, and it's GetAddressBytes method? You might even look at its HostToMetworkOrder and NetworkToHostOrder methods, depending on what you're doing with the byte version of the address.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      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