473,225 Members | 1,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

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

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?

Sep 24 '07 #1
3 2408

"cmdolcet69" <co************@hotmail.comha scritto nel messaggio
news:11**********************@57g2000hsv.googlegro ups.com...
>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
Sep 24 '07 #2
On Sep 24, 8:10 am, cmdolcet69 <colin_dolce...@hotmail.comwrote:
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

Sep 25 '07 #3
Giovanni Dicanio wrote:
"cmdolcet69" <co************@hotmail.comha scritto nel messaggio
news:11**********************@57g2000hsv.googlegro ups.com...
>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
Or if you want to write a single byte from the array:

moRS232.Write(Packet, i, 1);

--
Göran Andersson
_____
http://www.guffa.com
Sep 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chumley the Walrus | last post by:
I'm using this sql parameter: MyCommand.Parameters("@Sport").value = Server.HtmlEncode(sport) to get a value from a textbox control: <asp:TextBox Name="sport" id="sport"...
12
by: Francois Grieu | last post by:
The values of ((int)0.7) and ((int)-0.7) seem to be 0 Is this independent of implementation ? TIA, François Grieu
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
2
by: Joe | last post by:
Hello, I'm trying to deserialize my objects (which derive from CollectionBase) using the special constructor. Everything works fine until I go to set the value. I get the following error:...
1
by: David Lozzi | last post by:
Howdy, I am trying to accomplish the following: dim DateSend as date if txtDateSend.text = "" then DateSend = dbnull.value else DateSend = txtDateSend.text
9
by: David | last post by:
I am getting the following error during run-time compilation or a rebuild all of my application: error BC30311: Value of type 'mynamespace.x' cannot be converted to 'mynamespace.x' This...
6
by: Sameh Ahmed | last post by:
Hello there I need to get the "PwdLastSet" of a user object to know when he last set his password. I am using DirectoryServices.DirectoryEntry to bind to the user object, but it either gives...
2
by: Jim in Arizona | last post by:
I'm learning form an ASP.NET 1.0 book and I tried out some code that returns this error: Compiler Error Message: BC30311: Value of type 'Integer' cannot be converted to...
2
by: DraguVaso | last post by:
Hi, I'm getting in trouble with the Generic.List(Of T). When declaring a Shadoiws of Mybase.Add, I want to do some custom actions with the item, and cast it to another class. The problem is...
69
by: Horacius ReX | last post by:
Hi, I have the following program structure: main ..... int A=5; int* ptr= A; (so at this point ptr stores address of A) ..... .....
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.