VB 6.0 - Attaching, configure Barcode reader and write the data into a text box

Asked By Pratik Kantharia on 19-Jan-12 12:56 AM
I want to user a barcode reader in VB 6.0. So how can i use it.
I want a string in a specified text box.

so please guide me.
smr replied to Pratik Kantharia on 19-Jan-12 12:59 AM

There are really two ways that this can happen.

First, using a scanner with a keyboard interface. You just piggyback the kayboard and the scanner. When anything is scanned it will appear as though it was typed on the keyboard.

Second, using a scanner that has a serial interface. You can us the MSCOMM control in VB6 to monitor the port and you'll receive a string from the scanner

Jitendra Faye replied to Pratik Kantharia on 19-Jan-12 01:05 AM
Actually, each manufacturer will have their own class libraries for accessing the barcode scanner. For example, Symbol is having their own class library for .NET called http://support.symbol.com/support/search.do?cmd=displayKC&docType=kc&externalId=11489&sliceId=&dialogID=4899679&stateId=0%200%204895369.
Jitendra Faye replied to Pratik Kantharia on 19-Jan-12 01:06 AM
For VB 6.0-

how can i write into serial port buffer through VB6 using mscomm my code is

Private Sub Command1_Click()
On Error GoTo errHandler

MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
MSComm1.Output = "Hey its working" 'Text1.Text
MsgBox MSComm1.OutBufferCount
MSComm1.PortOpen = False


MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
MsgBox MSComm1.InBufferCount
MSComm1.InputMode = comInputModeText
'Text1.Text = MSComm1.Input
MsgBox MSComm1.Input
MSComm1.PortOpen = False

If Err.Number <> 0 Then
MsgBox "Error No: " & Err.Number & ", Error Description: " & Err.Description
End If
End Sub
D Company replied to Pratik Kantharia on 19-Jan-12 01:14 AM
Hello Pratik ,

here is one sample programm for bar code in VB , will surely help you.

Private Sub mscomm2_OnComm()
  Dim sBarScan as string
  If iFlag = 1 Then Exit Sub
  If flag = 1 Then   'Text boxes empty?
    For i = 0 To 2
      txt(i) = ""
    Next i
    flag = 0
  End If

// asign in a varibale
  sBarScan = left(MSComm1.Input, 12)
// selecte from table
  rs.Open ("SELECT * from ItemInfo where Identifier = '" & sBarScan & "'")   'ItemInfo is table in my db
    iDeptNum = rs(3)  'Get Dept# for scanned item
    DeptAmt = rs(2)   'Get amt for scanned item
    SubAmt = SubAmt + rs(2) 'This is subtotal
    txt(0) = txt(0) & rs(1) & vbCrLf  'Add itemDescript to display
    txt(1) = txt(1) & FormatNumber(DeptAmt, 2) & vbCrLf  'Add amount of item to display