Hi Everybody
I am stuck can somebody help me please.

I am testing a very small portable barcode scanner.
After scanning I need to upload the scanned data.

I am in VB6 I am using the mscomm1 control
I tell the scanner to send the data.
I have a OnCom procedure that reads the data and sends it to the
handleInput procedure.
As you can see this output goes to the Text1 box

Case comEvReceive ' Received RThreshold # of chars.
InBuff = MSComm1.Input
Call HandleInput(InBuff)

Sub HandleInput(InBuff As String)
' This is where you will process your input. This
' includes trapping characters, parsing strings,
' separating data fields, etc. For this case, you
' are simply going to display the data in the TextBox.
Text1.SelStart = Len(Text1.Text)
Text1.SelText = InBuff
End Sub

The text in the text box looks like this:-

I need help to list just the barcodes in a list or place all the data in an array
In the above 13734G 2229KP are the barcodes.

This is what the documentation tells me about the data string

Output: A multi-byte string (see below).
Purpose: Read all barcodes data stored in KDC100 internal flash memory. Does not erase the stored barcodes.
The format of the output is as follows:
N C0 Y0 D0 T0 C1 Y1 D1 T1 . . . . . . . . . . . . . . . . . . . Cn Yn Dn Tn
N : Total number of bytes to be sent(3 bytes)
C0, C1,…, Cn : Total number of each barcode data(1 byte)
Y0,Y1,…, Yn : Type of each barcode(1 byte)
D0,D1,…,Dn : Actual barcode data of each barcode(variable size)
T0, T1,…,Tn : Timestamp of each barcode(4 bytes)
The first 3 bytes specify the total number of bytes being sent. Then the entire populated contents of the internal flash memory are sent as is.

I have attached my text box text, it might have lost its correct format in the copy process .

I would be very pleased for some help,
Best regards,

Recommended Answers

All 7 Replies

try to use MID fuction for the purpose.

make that dynamic.

3 first bytes and 2 second ones are crc if i understand it correctly

Try with these to see actual bytes you received:

Sub HandleInput(InBuff As String)
Dim ArrOfBytes() as byte
Dim lonLenOfInput as Long

Redim ArrOfBytes(100)

lonLenOfInput = len(intbuff)

If LenOfInput > 100 then
Redim ArrOfBytes(lonLenOfInput)
End if

For i = 1 to lonLenOfInput
     ArrOfBytes(i) = asc(mid(InBuff, i , 1))

Inbuff = ""

end sub

Sorry if code isnt exactly correct but from ur post i think that
ArrOfBytes(1) and ArrOfBytes(2) and ArrOfBytes(3) should be N high high byte, highybyte and low byte value witch represent number of bytes in entire message
ArrOfBytes(4) should be C0 number of bytes after Y0
ArrOfBytes(5) should be Y0 or Header of barcode message (since ill assume thease number will allways be same one)
ArrOfBytes(6) to ArrOfBytes(6 + ArrOfBytes(4)) data bytes
ArrOfBytes(6 + ArrOfBytes(4) + 1) should be terminator or the end of message for that barcode.

I hope i got it right or at least give u some idea.

Hi Teropod,
Thank you for that, that has helped a lot.
I have another question if you can help
When I ask the scanner how many barcodes have been read into the scanner. Using your code I get 4 bytes ArrOfBytes(0), ArrOfBytes(1),ArrOfBytes(),ArrOfBytes(3)
This is the output 0,0,0,255 This I understand as I have 255 barcodes in the scanner. 0,0,1,0 This is the result for 256 codes in the scanner. 0,0,1,5 is for 261.
I see how that works.
The handbook gives the following information if I want to upload one specific barcode.
Parameters: The number which indicates the position of barcode data to be sent.
Format: ‘pxxxxxxxx#’ where xxxxxxxx is the number of barcode data stored in the internal flash to upload
in hexadecimal.
Output: A multi-byte string (see below). KDC100 sends only one barcode data at one time.
Purpose: Read the Nth barcodes data stored in KDC100 internal flash memory. Does not erase the barcode.
Everything I have tried gives me the the first barcode, which must be the default.
"p2#" , "p&H00000002&#" ,"pA#" ,"p00000002#"
Have you any advice about how one could enter the number?
I thought I have to enter it in the same format as I get back when I ask how many barcodes are in the scanner.
Thank you very much for your help.
Best regards,

If you used my code arrofbytes(0) is all ways 0 since i started i from 1 to lenght of string if u wanna start from 0 then you need to modify code.

For i = 0 to lonLenOfInput - 1
ArrOfBytes(i) = asc(mid(InBuff, i + 1 , 1))

Look for ascii table in help those numbers you got in array are that strings.

And did they described how does response of how many barcode scanner have look alike?

Do you know how he stores barcodes is it in first in last out?
Do you get any message that he got new barcode or uyou have to pull him all the time?

Hi Teropod,
Sorry if I confused you. Your code was just fine and it dose just what I wanted. With the ASC values of the array I am able to create the full barcode data. There is not only the barcode string, there is the date/time, the scanner serial Nr., the type of barcode. I can now get all of that information and the total byte length of each Barcode data string.
Many thanks for your help,
Best regards,Tony

Hi Debasisdas,
Many thanks for that help. When I first read it. it took a little while before it clicked.
I had expected a far more complicated solution.
Thanks again.
Best regards,Tony

No problem! Good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.