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

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?
 
G

Giovanni Dicanio

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
 
C

Chris Dunaway

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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

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