How to make conversion?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dyc
    New Member
    • May 2007
    • 32

    How to make conversion?

    can make conversion in the byte to binary??

    thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by dyc
    can make conversion in the byte to binary??
    Perhaps this is what you're looking for? It's written in VB6, but may also work in later versions.

    [CODE=vb]Public Function Bin(ByVal ByteValue As Byte) As String
    Dim I As Long, BitValue As Long, BitWeight As Long
    For I = 0 To 7
    BitWeight = 2 ^ (7 - I)
    BitValue = ByteValue \ BitWeight
    Bin = Bin & Format(BitValue )
    ByteValue = ByteValue - BitValue * BitWeight
    Next
    End Function[/CODE]

    Comment

    • dyc
      New Member
      • May 2007
      • 32

      #3
      Originally posted by Killer42
      Perhaps this is what you're looking for? It's written in VB6, but may also work in later versions.

      [CODE=vb]Public Function Bin(ByVal ByteValue As Byte) As String
      Dim I As Long, BitValue As Long, BitWeight As Long
      For I = 0 To 7
      BitWeight = 2 ^ (7 - I)
      BitValue = ByteValue \ BitWeight
      Bin = Bin & Format(BitValue )
      ByteValue = ByteValue - BitValue * BitWeight
      Next
      End Function[/CODE]
      Erm...I quite not really understand about the code..Can u pls explain it ?
      thanks ya...

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by dyc
        Erm...I quite not really understand about the code..Can u pls explain it ?
        thanks ya...
        Well, since it's a function, you don't necessarily have to understand it. That's the beauty of a function - it can be used as a "black box" without worrying about the "innards".

        It takes in a byte value, and returns the string of "0" and "1" indicating the binary value of the byte. Try passing values to it from the immediate window. For example...
        Print Bin(38)

        If this isn't what you were after, then please explain further.

        Comment

        Working...