作者jeffy84123 (因为贴心所以是好人)
看板Visual_Basic
标题[VB2008]串列通讯程式的问题
时间Wed Aug 26 00:27:09 2009
我参考MSDN上的从COMPORT上读取字串
写了
Module Module1
Sub Main()
Dim Str As String
Str = ReceiveSerialData()
Console.WriteLine(Str)
Console.ReadLine()
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("COM3") '我的sensor在COM3上
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
End Module
可是一直没读到东西
请问是我哪里写错呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.73.175.14
1F:→ k80092:有试过先用超级终端机读过吗? 09/05 17:01