Read Data From Bar Code Scanner

Post Reply
User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Read Data From Bar Code Scanner

Post by US_Helpdesk » Tue Mar 26, 2013 4:51 pm

We have a code bar scaner and decicated software which put data from the scanned barcode(part name name and it's number) to txt file:
file layout is:

Code: Select all

part_name    part_no
aaa        001
bbb        002
ccc        003
Can cmm mgr's vb script function can grab these two values and put it automatically to the current program run?
(instead typing it each time running the program)
I've migrated to a new user account, see my other posts here

User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Re: Read Data From Bar Code Scanner

Post by US_Helpdesk » Tue Mar 26, 2013 4:55 pm

Yes this is possible… Here is the VB Script I put in a CMMM project to make this work. After writing the file to an Array you can access the data like this:

MyData = PrtNmb(#) or MyOtherData = PrtNm(#) ------- where # equals the line number of the file.


Here is a message box showing an Array Variable for Part Name and Part Number. This Array data can be used anywhere you can recall a Variable such as Report Header (Customer Data), DDE, etc. This Msg Box is displayed after this VB Script line:
MsgBox("Part Name: " + PrtNm(2)+" Part Number: "+PrtNmb(2))
MsgBox.jpg

Code: Select all

dim PrtNmb(100)
dim PrtNm(100)

Open "c:\barcode.txt" For Input As #1   ' Open file.
i =1
    Do While Not EOF(1)                   ' Loop until end of file.
                Line Input #1, TextLine   ' Read line into variable.
                FndSpc = InStr(TextLine, "   ")  ' Find series of spaces
                PlcHldr = FndSpc - 1
                PrtNm(i) = Left(TextLine, PlcHldr)  ' write text to Array


                StrReverse(TextLine)                  ' repeat for right side of string
                FndSpc = InStr(TextLine, "   ")
                PlcHldr = FndSpc - 1
                PrtNmb(i) = Right(TextLine, PlcHldr)

     i = i +1
    Loop
    Close #1           ' Close file.


'Message Box Output(s)
MsgBox("Part Name: " + PrtNm(2)+"  Part Number: "+PrtNmb(2))
MsgBox("Part Name: " + PrtNm(3)+"  Part Number: "+PrtNmb(3))
MsgBox("Part Name: " + PrtNm(4)+"  Part Number: "+PrtNmb(4))


'Create Variable(s) for use in Report Output
'Use Customer Data Field(s) in Report Properties
RptData = PrtNm(4)
RptData2 = PrtNmb(4)
You do not have the required permissions to view the files attached to this post.
I've migrated to a new user account, see my other posts here

User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Re: Read Data From Bar Code Scanner

Post by US_Helpdesk » Tue Mar 26, 2013 4:58 pm

Here is the project file...
You do not have the required permissions to view the files attached to this post.
I've migrated to a new user account, see my other posts here

User avatar
CrashN8
Site Admin
Site Admin
Posts: 367
Joined: Thu Feb 09, 2017 4:07 pm

Re: Read Data From Bar Code Scanner

Post by CrashN8 » Tue May 14, 2019 5:45 pm

Here is a quick video I've created that shows a new USB based barcode reader working with CMM-Manager.

I used a Zebra DS4308 scanner - Buy here on Amazon


Post Reply