Advertisement
RuiViana

VBA

Apr 14th, 2016
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. Public Function CommRead(intPortID As Integer, strData As String, _
  2. lngSize As Long) As Long
  3.  
  4. Dim lngStatus As Long
  5. Dim lngRdSize As Long, lngBytesRead As Long
  6. Dim lngRdStatus As Long, strRdBuffer As String * 1024
  7. Dim lngErrorFlags As Long, udtCommStat As COMSTAT
  8.  
  9. On Error GoTo Routine_Error
  10.  
  11. strData = ""
  12. lngBytesRead = 0
  13. DoEvents
  14.  
  15. ' Clear any previous errors and get current status.
  16. lngStatus = ClearCommError(udtPorts(intPortID).lngHandle, lngErrorFlags, _
  17. udtCommStat)
  18.  
  19. If lngStatus = 0 Then
  20. lngBytesRead = -1
  21. Cells(8, 1).Value = lngBytesRead
  22. lngStatus = SetCommError("CommRead (ClearCommError)")
  23.  
  24. GoTo Routine_Exit
  25. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement