Convert integer to bit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmdolcet69

    Convert integer to bit

    I have the following created in vb 2003:

    Public Bitvalue as byte()

    Public Sub Upload ()
    dim i as integer =0

    for i = 0 to 4095
    bitvalue=bitcon verted.getbytes (i)

    bitvalue(0)
    bitvalue(1)

    next

    end Sub


    When i look at my bitvalue (0) and bitvalue (1) if my i = 152 then
    my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
    for.... however i only see bitvalue(0) is 152


    Can anyone help?
  • rowe_newsgroups

    #2
    Re: Convert integer to bit

    On Aug 29, 9:21 am, cmdolcet69 <colin_dolce... @hotmail.comwro te:
    I have the following created in vb 2003:
    >
    Public Bitvalue as byte()
    >
    Public Sub Upload ()
    dim i as integer =0
    >
    for i = 0 to 4095
    bitvalue=bitcon verted.getbytes (i)
    >
    bitvalue(0)
    bitvalue(1)
    >
    next
    >
    end Sub
    >
    When i look at my bitvalue (0) and bitvalue (1)    if my i = 152 then
    my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
    for.... however i only see bitvalue(0) is 152
    >
    Can anyone help?
    I'm guessing it's converting it to a byte, but when you look at it
    through the watch window / drop down it's just displaying it as an
    integer.

    Thanks,

    Seth Rowe [MVP]

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Convert integer to bit

      "rowe_newsgroup s" <rowe_email@yah oo.comschrieb:
      >When i look at my bitvalue (0) and bitvalue (1) if my i = 152 then
      >my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
      >for.... however i only see bitvalue(0) is 152
      >>
      >Can anyone help?
      >
      >I'm guessing it's converting it to a byte, but when you look at it
      >through the watch window / drop down it's just displaying it as an
      >integer.
      That's what I guess too. Note that the watch window provides a context menu
      entry to turn to hexadecimal display of numbers.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Cor Ligthert[MVP]

        #4
        Re: Convert integer to bit

        Hi

        Maybe I miss something, but I don't understand your code, I see something
        that is named bitconverted comming from the air, is it possible to explain
        where that fields is comming from?

        Cor

        "cmdolcet69 " <colin_dolcetti @hotmail.comsch reef in bericht
        news:a4ae568d-6bac-44b9-b567-958cac5b4c0c@d1 g2000hsg.google groups.com...
        >I have the following created in vb 2003:
        >
        Public Bitvalue as byte()
        >
        Public Sub Upload ()
        dim i as integer =0
        >
        for i = 0 to 4095
        bitvalue=bitcon verted.getbytes (i)
        >
        bitvalue(0)
        bitvalue(1)
        >
        next
        >
        end Sub
        >
        >
        When i look at my bitvalue (0) and bitvalue (1) if my i = 152 then
        my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
        for.... however i only see bitvalue(0) is 152
        >
        >
        Can anyone help?

        Comment

        • James Hahn

          #5
          Re: Convert integer to bit

          Use this:
          Dim Bitvalue As Byte()
          Dim A As String
          Dim i As Integer = 0

          For i = 0 To 4095
          Bitvalue = BitConverter.Ge tBytes(i)

          A = Hex(Bitvalue(0) )
          A = Hex(Bitvalue(1) )

          Next

          but I do not understand why you expect 152 to be H08,H09. 152 is H98. I
          suspect you want this code to do something quite different. Is this an
          endian problem?

          "cmdolcet69 " <colin_dolcetti @hotmail.comwro te in message
          news:a4ae568d-6bac-44b9-b567-958cac5b4c0c@d1 g2000hsg.google groups.com...
          >I have the following created in vb 2003:
          >
          Public Bitvalue as byte()
          >
          Public Sub Upload ()
          dim i as integer =0
          >
          for i = 0 to 4095
          bitvalue=bitcon verted.getbytes (i)
          >
          bitvalue(0)
          bitvalue(1)
          >
          next
          >
          end Sub
          >
          >
          When i look at my bitvalue (0) and bitvalue (1) if my i = 152 then
          my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
          for.... however i only see bitvalue(0) is 152
          >
          >
          Can anyone help?

          Comment

          Working...