Page 1 of 1

Decode Bit-coded

Posted: Friday 13th November 2020 12:27pm
by tincho
Hello everyone.
I have a collection of numbers that according to the manual of the file I am trying to decode are bit-coded they should be 1, 2, 4, 16, 32, 64 but I get from the file:
1008, 992, 1017.
How do I decode the numbers in the second group to make them look like something in the first?
See index 70 for the list.

Re: Decode Bit-coded

Posted: Friday 13th November 2020 3:34pm
by vuott

Re: Decode Bit-coded

Posted: Friday 13th November 2020 4:33pm
by cogier
Is this what you are looking for?
TextBoxIn As TextBox
GridViewDisplay As GridView

Public Sub TextBoxIn_Change()

  Dim iLoop As Integer
  Dim sBin As String

  GridViewDisplay.Clear

  If Len(Trim(TextBoxIn.Text)) > 3 Then TextBoxIn.Text = Left(TextBoxIn.Text, -1)

  Try sBin = Bin(TextBoxIn.Text, 7)
  If Error Then
    If Trim(TextBoxIn.Text) = "" Then Return

    TextBoxIn.Text = Left(TextBoxIn.Text, -1)
  Endif

  If Val(TextBoxIn.Text) > 127 Then
    TextBoxIn.Clear
    Return
  End If

  For iLoop = 0 To 6
    GridViewDisplay[0, iLoop].Text = sBin[iLoop]
  Next

End

Public Sub Form_Open()

  Dim iLoop As Integer
  Dim sHeader As String[] = ["AutoCad\n64", "Resolved\n32", "Table entry\n16", "8", "Locked\n4", "Frozen\n2", "Frozen\n1"]

  With Me
    .H = 150
    .W = 500
    .Padding = 5
    .Arrangement = Arrange.Vertical
  End With

  With TextBoxIn = New TextBox(Me) As "TextBoxIn"
    .H = 28
    .PlaceHolder = "Enter an integer upto 127"
  End With

  With GridViewDisplay = New GridView(Me) As "GridViewDisplay"
    .Columns.Count = 7
    .Rows.Count = 1
    .Expand = True
    .Header = GridView.Horizontal
  End With

  For iLoop = 0 To 6
    GridViewDisplay.Columns[iLoop].Title = sHeader[iLoop]
    GridViewDisplay.Columns[iLoop].Alignment = Align.Center
  Next

End

Re: Decode Bit-coded

Posted: Tuesday 17th November 2020 10:53pm
by tincho
Yes !!! exactly.
Before see your code i made this with the help of tercoide.
Public Function DWGFlag(iFlag As Integer, iPos As Integer) As Byte
  Dim t As String
  Dim b As Byte
  t = Bin(iFlag, 8)
  b = CByte(Mid(t, 9 - iPos, 1))
  Return b
End
Regards.
Martin.