Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text jumps from one textbox to another after scan.

Status
Not open for further replies.

bigracefan

Programmer
Apr 2, 2002
304
US
I'm having an intermitent problem with my code or scanner. When I scan a barcode, it splits the scan into the textbox that has focus and the next textbox that gets focus. The premiss is scan barcode 1 into textbox 1, the the focus goes to textbox 2, etc. Here is what I'm using...


If txtSerial.Text = "" Then
If txtSerial.Tag <> &quot;Focused&quot; Then
txtSerial.SetFocus
txtSerial.Tag = &quot;Focused&quot;
End If
End If


If txtSerial.Text <> &quot;&quot; Then
SerialOK = True
If UCase(Mid(txtSerial.Text, 1, 1)) = &quot;S&quot; Then
InLabel = &quot;Star&quot;
ElseIf Mid(txtSerial.Text, 1, 2) = &quot;1S&quot; Then
InLabel = &quot;Delta&quot;
Else
MsgBox &quot;Invalid Scan. Please Scan Serial No.&quot;, vbInformation + vbOKOnly, &quot;Invalid Scan&quot;
txtSerial.Tag = &quot;&quot;
txtSerial.Text = &quot;&quot;
End If

If txtPartNum.Text = &quot;&quot; Then
For i = 1 To 30000
Next
txtPartNum.SetFocus
End If
End If


This routine sits in a timer with an interval of 1000. Is there a more effcient way to do a process like this?

Thanks.

Pete
 
Not sure if this is really what you were asking for but let me know if you need more

Code:
Private Sub Timer1_Timer()
    Dim Serials As Integer
    
    '//this way the focus will always stay on txtSerial which does not
    '//have any data
    For Serials = txtSerial.LBound To txtSerial.UBound
        If Len(txtSerial(Serials)) Then
            SerialOK = True
            If UCase(Mid(txtSerial(Serials).text, 1, 1)) = &quot;S&quot; Then
                InLabel = &quot;Star&quot;
            ElseIf Mid(txtSerial(Serials).text, 1, 2) = &quot;1S&quot; Then
                InLabel = &quot;Delta&quot;
            Else
                MsgBox &quot;Invalid Scan. Please Scan Serial No.&quot;, vbInformation + vbOKOnly, &quot;Invalid Scan&quot;
                txtSerial(Serials).text = &quot;&quot;
                txtSerial(Serials).SetFocus
            End If
        Else
            txtSerial(Serials).SetFocus
        End If
    Next
    If txtPartNum.text = &quot;&quot; Then
        For i = 1 To 30000
        Next
        txtPartNum.SetFocus
    End If
End Sub
 
OOOPs....forgot to tell you not that its not apparent but be sure txtSerial is a control array
 
Damn sorry its been a long week...add the following to the above code
Code:
dim ReceiveScan as integer
ReceiveScan = -1

'//then remove the lines that state txtSerial(Serials).SetFocus and enter the following
ReceiveScan = iif(ReceiveScan < 0, Serials, -1)
'//then before exiting timer
if ReceiveScan > 0 then
    txtSerial(ReceiveScan).Setfocus
Else
    '//all the availble txtserials are full
end if

'//This will always put you in the first empty txtserial
 
Does your scanner send a terminator at the end of a scan? The scanners I have worked with send a carriage return and line feed (Chr 13) at the end of the scan. If this is so, then you can look for that in the KeyPress event of your text box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top