JJ
2022-03-07 23:24:27 UTC
How to access the 3rd and rest elements of a Byte() (byte array)? Note: the
byte array is an array of bytes. It's not a variant array of bytes.
I could only access the first, the second, but I can't figure out how to
access the 3rd and rest of elements.
Below is an example whose input byte array is simulated. Actual byte array
came from an ActiveX where I can't control the element index or how many
elements to retrieve.
'simulate byte array creation
set ds = createobject("adodb.stream")
ds.open
ds.charset = "windows-1252"
ds.writetext "abcdefghijklmnopqrstuvwxyz"
ds.position = 0
ds.type = 1
arr = ds.read 'simulated byte array retrieval
'byte array access...
msgbox asc(a) 'first element as byte
v = ascw(a) 'first & second element as int (16-bit integer)
msgbox v \ 256 'second byte of above int (16-bit integer)
'how to access 3rd and rest of elements?
byte array is an array of bytes. It's not a variant array of bytes.
I could only access the first, the second, but I can't figure out how to
access the 3rd and rest of elements.
Below is an example whose input byte array is simulated. Actual byte array
came from an ActiveX where I can't control the element index or how many
elements to retrieve.
'simulate byte array creation
set ds = createobject("adodb.stream")
ds.open
ds.charset = "windows-1252"
ds.writetext "abcdefghijklmnopqrstuvwxyz"
ds.position = 0
ds.type = 1
arr = ds.read 'simulated byte array retrieval
'byte array access...
msgbox asc(a) 'first element as byte
v = ascw(a) 'first & second element as int (16-bit integer)
msgbox v \ 256 'second byte of above int (16-bit integer)
'how to access 3rd and rest of elements?