I have found out how to do the opposite of converting a integer to a 16 bit Boolean array by this.
Dim ND1_Array As New System.Collections.BitArray(System.BitConverter.GetBytes(Data(2)))
I have tried this
Dim barray(15) As Boolean : barray(0) = True : barray(2) = True : barray(4) = True
Dim bittoint As Integer
bittoint = Convert.ToInt32(barray(0), 0)
This code throws an error so ? I have looked all over the net but can't find how to do this.
bittoint = BitConverter.ToInt32(barray(0), 0)
This has an error as well Error 1 Value of type 'Boolean' cannot be converted to '1-dimensional array of Byte'. C:\PLC\TCPClientClean\TCPClientClean\ChatClient.vb 201 41 TCPClientClean
This is what I came up with. Not sure what is the better method? I just saw the new updated code that was provided.
Dim BoolStg As String
Dim BoolArra1DexBit As Boolean
Dim BitArray1ToInt16 As Integer
For BarryDex = 0 To 15
BoolArra1DexBit = BoolAray1(BarryDex)
If BoolArra1DexBit = True Then
BoolStg = "1" & BoolStg
Else : BoolStg = "0" & BoolStg
End If
Next
BitArray1ToInt16 = Convert.ToInt16(BoolStg, 2)
BitConverter.ToInt16/32instead.on.