Option Strict and reading bytes from File

K

Kejpa

Hi,
I want to read a fixed number of bytes from a file and when I turned on the
Option Strict I get an error I just can't fix.

The code:
Dim baInfo(99) As Byte
FileGet(iFilNr, baInfo, 5)

The Error:
Option Strict On disallows narrowing from type 'System.Array' to type
'1-dimensional array of Byte' in copying the value of 'ByRef' parameter
'Value' back to the matching argument.

Anyone any ideas?
/Kejpa
 
H

Herfried K. Wagner [MVP]

Kejpa said:
Dim baInfo(99) As Byte
FileGet(iFilNr, baInfo, 5)

The Error:
Option Strict On disallows narrowing from type 'System.Array' to type
'1-dimensional array of Byte' in copying the value of 'ByRef' parameter
'Value' back to the matching argument.

Untested:

\\\
FileGet(19, DirectCast(baInfo, Array), 5)
///
 
K

Kejpa

It worked, thanks a lot!

Do you have anything like it up the sleeve for reading structs?
I have the same problem there...

TIA
/Kejpa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top