Can anyone see a problem with this code? I'm testing with a USB scanner, tho I want to eventually use a raster. It doesn't seem to get past the Form Load. Data appears in the text box, but I'm not sure if it is serial, because it never gets to the OnComm event. ENTER key doesn't fire it, either.
Option Explicit
Public prod As String
Public lot As String
Public scan As String
Public Inbuff As String
Private Sub Form_Load()
With MSComm1
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
End With
txtscandata.Text = ""
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
Inbuff = Inbuff & MSComm1.Input
scan = MSComm1.Input
If Len(Trim(Inbuff)) >= 12 Then
Call HandleInput
Else
Exit Sub
End If
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
Sub HandleInput()
txtscandata.SelLength = Len(txtscandata.Text)
'txtscandata.SelText = InBuff
txtscandata.Text = scan
prod = Mid(scan, 1, 6)
MsgBox prod, scan, txtscandata.Text
scan = ""
Inbuff = ""
End Sub
Option Explicit
Public prod As String
Public lot As String
Public scan As String
Public Inbuff As String
Private Sub Form_Load()
With MSComm1
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.RThreshold = 1
MSComm1.PortOpen = True
End With
txtscandata.Text = ""
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
Inbuff = Inbuff & MSComm1.Input
scan = MSComm1.Input
If Len(Trim(Inbuff)) >= 12 Then
Call HandleInput
Else
Exit Sub
End If
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
Sub HandleInput()
txtscandata.SelLength = Len(txtscandata.Text)
'txtscandata.SelText = InBuff
txtscandata.Text = scan
prod = Mid(scan, 1, 6)
MsgBox prod, scan, txtscandata.Text
scan = ""
Inbuff = ""
End Sub