Byte in Bits

    • VB.NET

      Byte in Bits

      Hi,

      hier hab ich noch einen Code, mit dem man ein Byte in die einzelnden Bits (als String) zerlegen kann:

      VB.NET-Quellcode

      1. Function aufteilen(ByVal b As Byte) As String
      2. Dim text As String = "00000000"
      3. Dim i As Integer = 0
      4. For a As Integer = 8 To 1 Step -1
      5. i = 128 / Math.Pow(2, 8 - a) 'aktuelle Zweierpotenz bestimmen
      6. If b > i Then
      7. b -= i
      8. text = text.Substring(0, 8 - a) & "1" & text.Substring(8 - a + 1)
      9. End If
      10. Next
      11. Return text
      12. End Function


      vG,
      Lupus