Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Help with an algorithm

Dan,
Sorry, I don't understand the significance of the "Expected" section.
Also, don't know where this data stream is coming from, but can't you just
dump it in a byte array, then work in each byte as you go.

Private Sub CommandButton1_Click()
Dim ByteData() As Byte
Dim i As Long
Dim j As Long
Dim BinaryStr As String

'Sample data
'ReDim ByteData(1 To 3)
'ByteData(1) = 203
'ByteData(2) = 14
'ByteData(3) = 78

ByteData=<From data stream

For i = LBound(ByteData) To UBound(ByteData)
For j = 7 To 0 Step -1
If (ByteData(i) And 2 ^ j) 0 Then
'Then j bit is set
BinaryStr = BinaryStr & "1"
Else
BinaryStr = BinaryStr & "0"
End If
Next
Debug.Print "Byte: " & i, "Hex: " & Hex(ByteData(i)), "Dec: " &
ByteData(i), "Bit Set Count: " & BinaryStr
BinaryStr = ""
Next

End Sub

NickHK

"Dan" wrote in message
...
Need help in determining an algorithm to extract bit/byte information from

a
data stream. I know the where the bit/byte starts and the lenght to

extract,
but the problem is extracting the information correctly.

7 - 0 15 - 8 23 - 16 31 - 24 39 - 32 47 - 40 55 - 48
7654_3210 5432_1098 3210_9876 1098_7654 9876_5432 7654_3210 5432_1098
03 C2 FF A0 78 23 F6

The first and second rows above sequence is to show the bit location

within
the sequence. The third is the actual data that will be received.

The problem is that bit information (8 bits or less) is read right to left
and byte information (9 bits and greater) is read left to right.

Expected
Value Bit Length Variable
0 0 1 A
0 1 1 B
0 3 1 C
0 4 1 D
0 5 1 E
0 6 1 F
0 7 1 G
0 8 1 H
1 9 1 I
0 10 3 J
1 13 1 K
0 14 1 L
1 16 1 M
1 18 1 N
1 19 1 O
1 20 1 P
5A 24 8 Q
5A 32 8 R
002D 47 16 S

Thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Help with an algorithm

The data stream is from another file that I am importing and reviewing the
data line by line.

I will try to simplify the question and repost.

Thanks

"NickHK" wrote:

Dan,
Sorry, I don't understand the significance of the "Expected" section.
Also, don't know where this data stream is coming from, but can't you just
dump it in a byte array, then work in each byte as you go.

Private Sub CommandButton1_Click()
Dim ByteData() As Byte
Dim i As Long
Dim j As Long
Dim BinaryStr As String

'Sample data
'ReDim ByteData(1 To 3)
'ByteData(1) = 203
'ByteData(2) = 14
'ByteData(3) = 78

ByteData=<From data stream

For i = LBound(ByteData) To UBound(ByteData)
For j = 7 To 0 Step -1
If (ByteData(i) And 2 ^ j) 0 Then
'Then j bit is set
BinaryStr = BinaryStr & "1"
Else
BinaryStr = BinaryStr & "0"
End If
Next
Debug.Print "Byte: " & i, "Hex: " & Hex(ByteData(i)), "Dec: " &
ByteData(i), "Bit Set Count: " & BinaryStr
BinaryStr = ""
Next

End Sub

NickHK

"Dan" wrote in message
...
Need help in determining an algorithm to extract bit/byte information from

a
data stream. I know the where the bit/byte starts and the lenght to

extract,
but the problem is extracting the information correctly.

7 - 0 15 - 8 23 - 16 31 - 24 39 - 32 47 - 40 55 - 48
7654_3210 5432_1098 3210_9876 1098_7654 9876_5432 7654_3210 5432_1098
03 C2 FF A0 78 23 F6

The first and second rows above sequence is to show the bit location

within
the sequence. The third is the actual data that will be received.

The problem is that bit information (8 bits or less) is read right to left
and byte information (9 bits and greater) is read left to right.

Expected
Value Bit Length Variable
0 0 1 A
0 1 1 B
0 3 1 C
0 4 1 D
0 5 1 E
0 6 1 F
0 7 1 G
0 8 1 H
1 9 1 I
0 10 3 J
1 13 1 K
0 14 1 L
1 16 1 M
1 18 1 N
1 19 1 O
1 20 1 P
5A 24 8 Q
5A 32 8 R
002D 47 16 S

Thanks




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looking for my perfect algorithm meesh7391 Excel Discussion (Misc queries) 0 January 11th 06 12:06 AM
Algorithm Challenge Lowkey Excel Worksheet Functions 4 July 20th 05 06:40 PM
algorithm creation Gixxer_J_97[_2_] Excel Programming 11 February 11th 05 04:24 PM
help with algorithm dreamer[_3_] Excel Programming 6 January 9th 04 02:14 PM
Need help with algorithm RADO[_3_] Excel Programming 1 November 4th 03 12:37 PM


All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"