ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What is InBufferCount? (https://www.excelbanter.com/excel-programming/280811-what-inbuffercount.html)

No Name

What is InBufferCount?
 
Can someone explain what is InBufferCount? I am trying to
dignose code on some machines that continue at the loop.

Public Function GetWeight() As Double
Dim sInput As String

On Error GoTo ErrorHandler

ActiveCell.Value = "Waiting for Stable..."
frmComm.comExcel.CommPort = 1
frmComm.comExcel.Settings = "9600,N,7,2"
frmComm.comExcel.PortOpen = True
frmComm.comExcel.Output = "1S" & Chr$(13) 'Print on
stable
frmComm.comExcel.Output = "P" & Chr$(13) 'Display data

Do
DoEvents
Loop Until frmComm.comExcel.InBufferCount = 18

sInput = frmComm.comExcel.Input
frmComm.comExcel.PortOpen = False

GetWeight = Val(Mid$(sInput, 1))

Exit Function

ErrorHandler:
If Err.Number = 8005 Then
Exit Function
Else
MsgBox Err.Description
End If
End Function

Tom Ogilvy

What is InBufferCount?
 
It tells you how many characters are in the buffer waiting to be read.

--
Regards,
Tom Ogilvy

wrote in message
...
Can someone explain what is InBufferCount? I am trying to
dignose code on some machines that continue at the loop.

Public Function GetWeight() As Double
Dim sInput As String

On Error GoTo ErrorHandler

ActiveCell.Value = "Waiting for Stable..."
frmComm.comExcel.CommPort = 1
frmComm.comExcel.Settings = "9600,N,7,2"
frmComm.comExcel.PortOpen = True
frmComm.comExcel.Output = "1S" & Chr$(13) 'Print on
stable
frmComm.comExcel.Output = "P" & Chr$(13) 'Display data

Do
DoEvents
Loop Until frmComm.comExcel.InBufferCount = 18

sInput = frmComm.comExcel.Input
frmComm.comExcel.PortOpen = False

GetWeight = Val(Mid$(sInput, 1))

Exit Function

ErrorHandler:
If Err.Number = 8005 Then
Exit Function
Else
MsgBox Err.Description
End If
End Function





All times are GMT +1. The time now is 10:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com