这是写了的部分
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim n As Integer
Dim rxdata(2) As Byte
SerialPort1.PortName = "COM9"
n = Me.SerialPort1.BytesToRead '接收到的字节数
If (n > 0) Then ReDim rxdata(n - 1)
Me.SerialPort1.Read(rxdata, 0, n)
SerialPort1.Close()
End Sub
非常谢谢您这么详细的答案,但是我的VS 2012上是没有MScomm控件的,只能采用SerialPort进行控制啊!
追答找找看,我机器里没安装VS2012