Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String
Using com1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM1",9600,None,8,1)
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
Private Sub Button7_Released()
Dim returnStr As String
returnStr = ""
Dim com1 As IO.Ports.SerialPort
com1 = My.Computer.Ports.OpenSerialPort("COM1", 9600, None, 8, 1)
Do
Dim Incoming As String
Incoming = com1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr = Incoming & vbCrLf
End If
Loop
com1.Close ("COM1")
Return returnStr
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
11 déc. 2013 à 10:27
Dim mySerialPort As New SerialPort("COM1")
Je précise je débute en VB mais je peux apprendre très vite. :)