当前位置:编程学习 > C#/ASP.NET >>

vb.net2005 16进制发送与接受

我有个设备,需要发送一个16进制然后返回一个16进制结果给我。以下是我的代码。好像发送过去机器没有接受,但是用窜口助手就可以传。大家帮我看看我哪里写错了?机器只能接受16进制
Dim test As String = Nothing
        Dim TestArray() As String = Split(TextBox2.Text)
        Dim hexBytes() As Byte
        ReDim hexBytes(TestArray.Length - 1)
        Dim i As Integer
        For i = 0 To TestArray.Length - 1
            hexBytes(i) = Val("&h" & TestArray(i))
        Next
        

        Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("com1", 19200)
            
            com1.DtrEnable = True
            com1.Write(hexBytes, 0, hexBytes.Length)
            test = com1.ReadLine
            TextBox1.Text = test
            com1.Close()
        End Using
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,