how to get rid of the blank label after printing

Hello Experts,
We are trying to print labels from an old application still working.
We used vb6 and vfp9, to develop a very small routine,
but both modules after printing always print a blank label.
How can we stop this blank label from being printed ??
Regards!
RGuillermoProject ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Can you post the VB6 routine that you are using?
0
RGuillermoProject ManagerAuthor Commented:
Martin Liss,
Here you have my code in vb6

Private Sub Command1_Click()
   Snippet
End Sub

Private Sub Form_Load()
For i = 0 To Printers.Count - 1
' if the specified printer is found select it
    If InStr(UCase(Printers(i).DeviceName), "ZEBRA") > 0 Then
        Set Printer = Printers(i)
        SelectPrinter = True
        Exit For
    End If
Next i
If Not SelectPrinter Then
    MsgBox "Unable to find Zebra printer ", vbOKOnly + vbExclamation, " Error"
    End
End If

'Check Code 128 Barcode Font is installed.
Dim bCompare As Boolean
Dim strFont As String

strFont = "Code 128"
For i = 0 To Screen.FontCount - 1
 If Screen.Fonts(i) = "Code 128" Then strScreenFont = "Code 128"
Next

bCompare = StrComp(strFont, strScreenFont, vbTextCompare) = 0

If Not (bCompare) Then
    MsgBox "Barcode font not installed. Reverting to printing non-barcode label.", vbInformation, "Barcode Font Not Installed!"
    bPrintBarcode = False
Else
    'Barcode font installed
    bPrintBarcode = True
End If
End Sub

Open in new window



'Snippet from the printing routine that demonstrates switching font from barcode to courier font...

Sub Snippet()

'Label_WithBarcode:
        'If bPrintBarcode = True Then
            
            With Printer
            .ScaleMode = vbCentimeters
            .Orientation = 1
            .Font = "Code 128"
            .FontSize = 38
            .FontBold = False
            .FontItalic = False
            .CurrentX = 1.2
            .CurrentY = -0.15
         
            Printer.Print "19293929"
            .Font = "Courier New"
            .FontSize = 11
            .FontBold = True
            .FontItalic = False
            .CurrentX = 0
            .CurrentY = 0.3
            Printer.Print Space(4) & "19293929"

            .CurrentX = 0
            .CurrentY = 1.15
            .FontSize = 15
            Printer.Print Space(1) & StrConv(Surname, vbUpperCase)

            .FontSize = 11
            .CurrentY = 1.6
            Printer.Print Space(17) & StrConv(Forenames, vbUpperCase)
            
            Printer.Print " DofB: " & "13/2/2011" & Space(5) & "Gender : " & "(" & "Male" & ")"

            .FontSize = 5
            Printer.Print Space(1)
            .FontSize = 11

        'End If
            .EndDoc
         End With
'        End If

End Sub

Open in new window

0
RGuillermoProject ManagerAuthor Commented:
Attached is the Project in rar file
BARCODE.vbw
BARCODE.frm
BARCODE.vbp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
Could it be that you are trying to print too much on the label and the Printer.Print Space(1) line causes it to overflow onto the next label. To test that you could either comment out the line or change it to something like Printer.Print "overflow?".
0
RGuillermoProject ManagerAuthor Commented:
I just tried only printing the bar code that is half the size of the label,
even then the printers makes another blank label.
0
RGuillermoProject ManagerAuthor Commented:
I discovered the

.enddoc

line closes the printing and causes the printer  to feed one more label in blank.

Is there something that can be done with this particular line in order to stop it from advancing one more blank label each time I finish printing a label?
0
Martin LissOlder than dirtCommented:
Try this before the enddoc.

.CurrentY = 0

BTW in you're existing code you have .CurrentY = -0.15 which is strange. Why isn't that just zero?
0
SimonCommented:
From memory, I think the .CurrentY =-0.15 was to get the barcode to print at max font size and still fit all the label data on the page height. It was because we didn't need the full height of the barcode at that font size but did want the width for maximum readability by the barcode scanners.
We didn't have an issue with blank labels being printed (using Zebra TLP2824 and TLP2824Z printers), but you're using a different model, probably with different media size. For example, we knew that with the field lengths we had, none of the printer would overflow the page width using that fixed width font size.
I did hack down the code drastically to provide the example. I'd suggest setting .CurrentY =0 and reducing the barcode font size while you're testing, to ensure that isn't causing the page-throw, and also appending ";" to your last Printer.print statement to suppress the last linebreak e.g.
.print "syx";
.enddoc
End With

Open in new window


If that doesn't work, i suggest you comment out all label printing lines except the barcode to start with and see if the problem persists, and then add one line of print at a time until you find where it causes a problem.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RGuillermoProject ManagerAuthor Commented:
Here is my latest code, still getting the blank label at the end,
SimonAdept, I tried testing each line separeately but all cause the blank label agter printing.

Please all I need is not to have that blank label at then end.....

Here is my latest code:

Private Sub Command1_Click()
   Snippet
End Sub

Private Sub Form_Load()
For i = 0 To Printers.Count - 1
' if the specified printer is found select it
    If InStr(UCase(Printers(i).DeviceName), "ZEBRA") > 0 Then
        Set Printer = Printers(i)
        SelectPrinter = True
        Exit For
    End If
Next i
If Not SelectPrinter Then
    MsgBox "Unable to find Zebra printer ", vbOKOnly + vbExclamation, " Error"
    End
End If

'Check Code 128 Barcode Font is installed.
Dim bCompare As Boolean
Dim strFont As String

strFont = "Code 128"
For i = 0 To Screen.FontCount - 1
 If Screen.Fonts(i) = "Code 128" Then strScreenFont = "Code 128"
Next

bCompare = StrComp(strFont, strScreenFont, vbTextCompare) = 0

If Not (bCompare) Then
    MsgBox "Barcode font not installed. Reverting to printing non-barcode label.", vbInformation, "Barcode Font Not Installed!"
    bPrintBarcode = False
Else
    'Barcode font installed
    bPrintBarcode = True
End If


End Sub

'Snippet from the printing routine that demonstrates switching font from barcode to courier font...
Sub Snippet()
  Dim X As Integer
'Label_WithBarcode:
        'If bPrintBarcode = True Then
  Open "c:\tmp\barcode_label.CSV" For Input As #1 Len = 60
  Input #1, w1, w2, w3, w4, w5, w6
  Input #1, w1, w2, w3, w4, w5, w6
  w_pro_cod = Trim(w1)
  w_bar_cod = Trim(w2)
  w_pro_des = Trim(w3)
  w_uni_pri = Trim(w4)
  w_exp_dat = Trim(w5)
  w_qty = Trim(w6)
  Close #1
           
            X = 2
            With Printer
           
            .ScaleMode = vbCentimeters
            .Orientation = 1
            .Font = "Code 128"
            .FontSize = 30
            .FontBold = False
            .FontItalic = False
            .CurrentX = 2.4
            .CurrentY = 0.3
             Printer.Print w_bar_cod
           
            .Font = "Arial Narrow"
            .FontSize = 11
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 0
            Printer.Print "Botica Paradera"
           
            .Font = "Arial Narrow"
            .FontSize = 14
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 1.3
            Printer.Print Space(8) & "F." & w_uni_pri;
           
            .Font = "Arial Narrow"
            .FontSize = 6
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 1.4
            Printer.Print w_exp_dat
           
            .Font = "Arial Narrow"
            .FontSize = 8
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 1.8
            Printer.Print w_pro_des
           
            .EndDoc
         End With
End Sub
0
SimonCommented:
Hi,

Did you try Martin's suggestion of setting CurrentY to zero before the .enddoc line?

The other questions I need to ask are:
Do you get a blank label (form feed) after printing to the printer by other methods  - e.g. just printing a single word text document to the printer?
Have you tried printing just a simple text string (no barcode) using the above code?

If you still get blank labels after testing the above items, I'd look at the printing preferences/defaults of the Zebra printer and get it to print its config sheet - usually by holding down the form-feed button until it flashes once or twice (you'd have to check the manual for your model if it's different).
0
RGuillermoProject ManagerAuthor Commented:
Yes I did try Martins suggestion, but still the ".enddoc" statement still releases one more blank label after finishing,
We migrated the whole source I sent you to visual basci 2013, its working fine now and problem solved.

Thank you Experts for all your effort and opiniĆ³n they were ery useful to us in order to finish our testing and decide what to do.

Best regards!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.