473,809 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(P acket(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 2447

"cmdolcet69 " <co************ @hotmail.comha scritto nel messaggio
news:11******** **************@ 57g2000hsv.goog legroups.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(P acket(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.comwro te:
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(P acket(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(P acket)

Chris

Sep 25 '07 #3
Giovanni Dicanio wrote:
"cmdolcet69 " <co************ @hotmail.comha scritto nel messaggio
news:11******** **************@ 57g2000hsv.goog legroups.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(P acket, 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
6492
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" runat="server"></asp:TextBox> but i cannot see why I get "Value of type 'System.Web.UI.WebControls.TextBox' cannot be converted to 'String'"
12
3222
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
5157
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. And K&R2 mentions "signed extension" everywhere. Reading some old clc posts, I've beginning to realize that these books are over-generalizing the topic. I am just wondering what the difference between the following pairs of terms are: 1)...
2
2796
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: "Object type cannot be converted to target type." The property Value of newField = 'ArrayList' and val also shows as ArrayList'.
1
2946
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
41965
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 occurs in only one component/project that accesses the 'x' object whereas several other components/projects also use the 'x' object in several other locations in exactly the same way without any problems. If I Rebuild
6
20123
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 "Argument 'Prompt' cannot be converted to type 'String'." or when I use .tostring it returns "system._comobject" I even tried to use this line but it also failed dater.FromFileTimeUtc(entry.Properties("pwdlastset").Value) 'ast from type...
2
7215
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 'ASP.multiclasses_aspx.VehicleKey'. Source Error: Line 106:
2
8740
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 that I get the whole time this error: "value of type 'T' cannot be converted to 'clsBaseClass'". I get it with both CType and Directcast:
69
3346
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
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.