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. VB.net and System.Uint32

VB.net and System.Uint32

Scheduled Pinned Locked Moved Visual Basic
csharphelp
4 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.
  • 0 Offline
    0 Offline
    0pius
    wrote on last edited by
    #1

    I am try to write a Gnutella client in Vb.net and have hit a road bump. According to the interfaces GetHostIP (Isearch.GetHostIp) which uses the Variables ResultID, HostID, SearchID returns 4 bytes representing the hosts IP. I have tried converting this to a Int32 using Converto.Int32 but I can never get any actual information all I get is 0. Can anyone help with getting a Uint32 value to display in VB.net ultimately it will be displayed in a listview. Cheers in Advance 0pius

    C 1 Reply Last reply
    0
    • 0 0pius

      I am try to write a Gnutella client in Vb.net and have hit a road bump. According to the interfaces GetHostIP (Isearch.GetHostIp) which uses the Variables ResultID, HostID, SearchID returns 4 bytes representing the hosts IP. I have tried converting this to a Int32 using Converto.Int32 but I can never get any actual information all I get is 0. Can anyone help with getting a Uint32 value to display in VB.net ultimately it will be displayed in a listview. Cheers in Advance 0pius

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

      If it's an IP address, wouldn't you want to convert every 8 bits into a number between 0 and 255 ? Have you checked the value you're trying to convert to see what's in it ?

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      0 1 Reply Last reply
      0
      • C Christian Graus

        If it's an IP address, wouldn't you want to convert every 8 bits into a number between 0 and 255 ? Have you checked the value you're trying to convert to see what's in it ?

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        0 Offline
        0 Offline
        0pius
        wrote on last edited by
        #3

        Christian, Thanks for your reply. Having never done this (recieved an uint32 or an IP address) could you point me in the right direction. Should I put it into an array, and then reference each byte.

        C 1 Reply Last reply
        0
        • 0 0pius

          Christian, Thanks for your reply. Having never done this (recieved an uint32 or an IP address) could you point me in the right direction. Should I put it into an array, and then reference each byte.

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

          You can use bit masking and bit shifting to get your four bytes out. For example: uint x = 348524; // whatever byte b1 = (x>>24); byte b2 = (x>>16) & 0xFF; byte b3 = (x>>8) & 0xFF; byte b3 =x & 0xFF; That's off the cuff, but it should work.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          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