[.NET] VS.2005下RS232的問題~請問程式碼哪裡出錯了?
在這邊ㄧ直接收不到資料
其中出錯的地方都是在
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
→
05/23 15:10, , 1F
05/23 15:10, 1F
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章