Board index » Visual Studio » Option Strict and reading bytes from File

Option Strict and reading bytes from File

Visual Studio54
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


-
 

Re:Option Strict and reading bytes from File

"Kejpa" <kSjPeAlMl@saj.fi>schrieb:

Quote
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)

///



--

M S Herfried K. Wagner

M V P <URL:dotnet.mvps.org/>">dotnet.mvps.org/>

V B <URL:dotnet.mvps.org/dotnet/faqs/>">dotnet.mvps.org/dotnet/faqs/>

-

Re:Option Strict and reading bytes from File

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



"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at>wrote in message

Quote
"Kejpa" <kSjPeAlMl@saj.fi>schrieb:

>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)

///



--

M S Herfried K. Wagner

M V P <URL:dotnet.mvps.org/>">dotnet.mvps.org/>

V B <URL:dotnet.mvps.org/dotnet/faqs/>">dotnet.mvps.org/dotnet/faqs/>





-