作者fire2 ( q )
看板Visual_Basic
标题[.NET] VS.2005下RS232的问题~请问程式码哪里出错了?
时间Tue May 23 14:48:33 2006
在这边ㄧ直接收不到资料
其中出错的地方都是在
Dim Incoming As String = com1.ReadLine()
後面的com1.ReadLine()这部份
试了好久,还是找不到错误
所以来这边请较ㄧ下
我是用COM1做测试
'将字串传送至序列埠
Sub SendSerialData(ByVal data As String)
' Send strings to a serial port.
Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("C
OM1")
com1.WriteLine(data)
End Using
End Sub
'接收来自序列埠的字串
Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""
Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("C
OM1")
Do
Dim Incoming As String = com1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
End Using
Return returnStr
End Function
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.71.22.72