运营商'&'没有为字符串插入定义和键入' byte()'在vb.net中

时间:2017-11-20 07:02:26

标签: vb.net

enter image description here

我尝试使用TCP发送数据,但错误显示运算符'&'未定义字符串插入和键入' byte()'。

Dim ms1 As New MemoryStream
Dim ms2 As New MemoryStream
Dim data1 As Byte()
Dim data2 As Byte()

PictureBox1.Image.Save(ms1, ImageFormat.Jpeg)
PictureBox2.Image.Save(ms2, ImageFormat.Jpeg)

data1 = ms1.ToArray()
data2 = ms2.ToArray()

Dim sendbytes() As Byte = System.Text.Encoding.ASCII.GetBytes(Passenger_idTextBox.Text & "," & Last_nameTextBox.Text & "," & First_nameTextBox.Text & "," & Middle_nameTextBox.Text & "," & StreetTextBox.Text & "," & BarangayTextBox.Text & "," & CityTextBox.Text & "," & Contact_celfoneTextBox.Text & "," & Contact_landlineTextBox.Text & "," & Contact_emailTextBox.Text & "," & AgeTextBox.Text & "," & ComboBox1.ValueMember & "," & ProfessionTextBox.Text & "," & data1 & "," & data2)
TCPClientz.Client.Send(sendbytes)

1 个答案:

答案 0 :(得分:0)

data1和data2是字节数组,而不是字符串。 你不能使用&连接字节数组。 这是一种如何连接字节数组的方法:

Dim x As Byte() = Convert.FromBase64String("test")
Dim y As Byte() = Convert.FromBase64String("test")
Dim z As Byte()
Dim barr As New Collections.Generic.List(Of Byte)(x)
barr.AddRange(y)
z = barr.ToArray