VB.NET中的串行通信 [英] Serial communication in VB.NET

查看:73
本文介绍了VB.NET中的串行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了这么多次,但是每次我从vb.net的串口接收数据时出错。请帮助解决我的问题。提前谢谢。



我的尝试:



< pre lang =vb> 私有 Sub ReceivedText( ByVal [text] 作为 字符串
' 将创建线程的ID与调用线程的ID进行比较
Dim PLCdata( 20 作为 整数
如果 .rtbReceived.InvokeRequired 然后
Dim x As SetTextCallback( AddressOf ReceivedText)
Me .Invoke(x, New 对象(){(text)})
调用 StrToHex(text)
其他
.rtbReceived.Text = sHex
' For Me.I = 1 to 15
' PLCdata(I)= ASC(Mid $(text,I,1))
' 下一步
结束 如果
结束 Sub

解决方案

(正文,我,1))
' 下一步
结束 如果
结束 Sub


As在评论中提到,您需要提供错误消息,让任何人都可以尝试帮助您。


Hi, i have tried so many time , But every time i got an error while receiving data from the serial port in vb.net.Please help to resolve my problem. Thank you in advance.

What I have tried:

Private Sub ReceivedText(ByVal [text] As String)
        'compares the ID of the creating Thread to the ID of the calling Thread
        Dim PLCdata(20) As Integer
        If Me.rtbReceived.InvokeRequired Then
            Dim x As New SetTextCallback(AddressOf ReceivedText)
            Me.Invoke(x, New Object() {(text)})
            Call StrToHex(text)
        Else
            Me.rtbReceived.Text = sHex
            ' For Me.I = 1 To 15
            'PLCdata(I) = ASC(Mid$(text, I, 1))
            'Next
        End If
    End Sub

解决方案

(text, I, 1)) 'Next End If End Sub


As mentioned in the comments, you'll need to provide the error message for anyone to even try and help you.


这篇关于VB.NET中的串行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆