Value of type byte cannot be converted to 1-dimentional array of byte

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
C

cmdolcet69

I can the following error message "value of type byte cannot be
converted to 1-dimentional array of byte" when i execute this line of
code:

moRS232.Write(Packet(i))

it underline the packet(i)

this is my declared array of byte size (6)

how can i fix this error?
 
cmdolcet69 said:
I can the following error message "value of type byte cannot be
converted to 1-dimentional array of byte" when i execute this line of
code:

moRS232.Write(Packet(i))

it underline the packet(i)

this is my declared array of byte size (6)

Maybe you should use the following Write overload:

Public Sub Write ( _
buffer As Byte(), _
offset As Integer, _
count As Integer _
)

So you can code like so:

moRS232.Write( Packet, 0, 6 );

to write 6 bytes starting from offset 0 (= 1st byte).

Giovanni
 
I can the following error message "value of type byte cannot be
converted to 1-dimentional array of byte" when i execute this line of
code:

moRS232.Write(Packet(i))

it underline the packet(i)

this is my declared array of byte size (6)

how can i fix this error?

Packet is your array of bytes, Packet(i) is only a single byte. You
need to pass Packet and Not Packet(i):

moRS232.Write(Packet)

Chris
 
Giovanni said:
Maybe you should use the following Write overload:

Public Sub Write ( _
buffer As Byte(), _
offset As Integer, _
count As Integer _
)

So you can code like so:

moRS232.Write( Packet, 0, 6 );

to write 6 bytes starting from offset 0 (= 1st byte).

Giovanni

Or if you want to write a single byte from the array:

moRS232.Write(Packet, i, 1);
 
Back
Top