probiers mal so:
dim Buffer as string
Private Sub UserForm_Initialize()
MSComm1.CommPort = 1
MSComm1.Settings = "4800,E,7,1"
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
end sub
Private Sub UserForm_Terminate()
On Error Resume Next
MSComm1.Close
End Sub
Private Sub MSComm1_OnComm()
Dim strArray() As String
Dim tmpbuffer As String
Select Case MSComm1.CommEvent
Case comEventBreak ' A Break was received.
Label1.Caption = "Break"
Case comEventCDTO ' CD (RLSD) Timeout.
Label1.Caption = "CD Timeout"
Case comEventCTSTO ' CTS Timeout.
Label1.Caption = "CTS Timeout"
Case comEventDSRTO ' DSR Timeout.
Label1.Caption = "DSR Timeout"
Case comEventFrame ' Framing Error
Label1.Caption = "Frame Error"
Case comEventOverrun ' Data Lost.
Label1.Caption = "Data Lost"
Case comEventRxOver ' Receive buffer overflow.
Label1.Caption = "RX Overflow"
Case comEventRxParity ' Parity Error.
Label1.Caption = "Parity Error"
Case comEventTxFull ' Transmit buffer full.
Label1.Caption = "TX Full"
Case comEventDCB ' Unexpected error retrieving DCB
Label1.Caption = "DCB Error"
Case comEvSend '1 Send event.
Case comEvCD '5 Change in carrier detect line.
Case comEventTxFull
Case comEvReceive '2 Receive event.
buffer = buffer & MSComm1.Input
tmpPos = InStr(1, buffer, vbLf) ' 2. endzeichen
überprüfen
If tmpPos > 0 Then ' da ist ein VBLF drin, also
verarbeiten
strArray = Split(buffer, vbCr & vbLf)
For cnt = 0 To UBound(strArray()) - 1 'nur bis zum
vorletzten Array, da das letzte schon weider was vom neuen enthalten
könnte
' hier die empfangenen Daten splitten und
verschicken
Next cnt
buffer = strArray(UBound(strArray()))
End If
End Select
End Sub
Wenn du net zurechtkommst, dann schick einfach mal das Excelfile
mfg thomas