Previous in Forum: Setting up a Win 98SE Guest in VirtualBox with file sharing   Next in Forum: Load Measurement
Close
Close
Close
3 comments
Rate Comments: Nested
Active Contributor

Join Date: Jan 2008
Location: India
Posts: 10

Barcode Code 128 Issue

06/26/2010 4:19 AM

I have written a small program in VB6 which prints barcode depending upon the user input. I have used Zebra printer software for design and using print to file option created a .prn file

I pass on the info to the variable in the prn file.This is working successfully from the past 8 months. Now all of sudden the barcode being printed is different from the type it should be. This barcode doesnt get scanned.

So I printed the same barcode serial no using Zebra software with Code 128. This is being read by the scanner.Using the same format I created .prn file and used to print the same serial no barcode from the VB program. Both of them are slightly differrent.

eg : SQRCXFT01645

Now I am unable to understand that how come a program working good for so long and there is no way the code was changed can bring up such issues.

I use the following function to pass on the variable info:

Function ReplaceStr(ByVal Origstr As String, ByVal Searchstr As String, ByVal ReplStr As String) As String
'Exchanges all occurrence of searchstr with replstr in origstr

'Here Searchstr is BARTEXT mentioned in .prn file whereas ReplStr is the serial no generated thru the program
'
Dim pos As Long
Dim i As Integer
Dim first As String
Dim last As String
'
' Origstr = ""
pos = 1
Dim tempnos As Integer

'
For i = 1 To 10 'find max. 10 occurrences
pos = InStr(pos, Origstr, Searchstr)

If pos > 0 Then

first = Mid$(Origstr, 1, pos - 1)
last = Mid$(Origstr, (pos + Len(Searchstr)), (Len(Origstr) - Len(first) - Len(Searchstr)))
Origstr = first + ReplStr + last
Else

Exit For
End If
Next i

ReplaceStr = Origstr 'Replace string with original data

End Function

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Oct 2009
Posts: 1460
Good Answers: 30
#1

Re: Barcode Code 128 Issue

06/27/2010 4:54 AM

I'm afraid we need more information, because your snippet of code is not sufficient to reveal the problem. It is more likely that somewhere else in the program a variable has not been properly declared and initialised. In your function, however, you should consider using a while...wend loop rather than a for...if...then...exit for...end if...next construction, as that will deal with any number of occurrences of search text, and look much tidier.

Register to Reply
Guru

Join Date: Feb 2010
Posts: 1013
Good Answers: 36
#2

Re: Barcode Code 128 Issue

06/27/2010 4:43 PM

As suggested by #1

I guess that the For … next might be limiting the number of occurrences of the string you are searching. Maybe you have reached a point where the serial number being converted has some kind of occurrence that is more than 10 or a character that is not taken care of in the string to be searched, therefore giving a wrong code???

To replace the for next with a Do … Loop -à

Function ReplaceStr(ByVal Origstr As String, ByVal Searchstr As String, ByVal ReplStr As String) As String
'Exchanges all occurrence of searchstr with replstr in origstr

'Here Searchstr is BARTEXT mentioned in .prn file whereas ReplStr is the serial no generated thru the program
'
Dim pos As Long
Dim i As Integer
Dim first As String
Dim last As String
'
' Origstr = ""

pos = InStr(pos, Origstr, Searchstr)

Do while pos > 0

first = Mid$(Origstr, 1, pos - 1)
last = Mid$(Origstr, (pos + Len(Searchstr)), (Len(Origstr) - Len(first) - Len(Searchstr)))
Origstr = first + ReplStr + last

pos = InStr(pos, Origstr, Searchstr)
Loop

ReplaceStr = Origstr 'Replace string with original data

End function

==== The loop will find all the occurrences even if more than 10 and will return if none is found ===============

More than that I cannot help without the remaining of the code.

I can only correct the logic of the code as far as I can guess what you are doing.

Register to Reply
Member

Join Date: Jul 2013
Posts: 6
#3
In reply to #2

Re: Barcode Code 128 Issue

11/05/2013 11:12 PM

er.haven't meet this kind of problem,but you may look at the article about barcode 128

Register to Reply
Register to Reply 3 comments
Copy to Clipboard

Users who posted comments:

LAA_Lucke (1); mariah (1); phph001 (1)

Previous in Forum: Setting up a Win 98SE Guest in VirtualBox with file sharing   Next in Forum: Load Measurement

Advertisement