Solved

Printing Barcode and text together in VB6

Posted on 2006-07-21
2
1,670 Views
Last Modified: 2013-12-03
Hello,

I need to print a text file in both Barcode font and normal font in VB6 program.
The text file has the following format:

       CaseNumber        Units       Date
       123456                3            06/01/06
       234567                5            06/07/06
       ..........                ..            .............

Now when I print this file, I need to print  the first column (CaseNumber) in Barcode font and the rest in normal font.
I know how to set the printer object's font to Barcode and print.
But, is it possible to mix two different fonts to print each row?

Thank you for your time.
0
Comment
Question by:JOSHUABT
2 Comments
 
LVL 5

Expert Comment

by:Davidshc76
ID: 17158561
It is possible to mix two different fonts to print each row..

DON'T OPEN IT IN NOTEPAD.....
TRY TO OPEN CURRENT TEXT FILE IN WORDPAD.............
CHANGE THE FONT AS YOU WANT.... THEN SAVE IT IN RTF FORMAT ......
0
 
LVL 4

Accepted Solution

by:
JRCSystems earned 500 total points
ID: 17163175
I am going to gather this document is not something typed in by hand (i.e. something that you'd want to open in notepad or wordpad), but rather something pulled from a database that you need to generate the report on the fly for.

The short answer to your question is "YES", VB can print different Fonts on the Same Row.
But I feel you were looking for more than just a "Yes".

What it sounds like to me is this: You need to experiment a bit more with VB's printer object to become a bit more familiar with it. Unlike DOS-driven dot-matrix printers, VB "draws" its image onto the page in memory, and when you issue a ".NewPage" or ".EndDoc" command, it sends that whole image at to the printer.

There are properties, such as ".CurrentX" and ".CurrentY", that not only tell you were the page's text-cursor/pointer is at, but let you set it. Consider this as an example:

Printer.ScaleMode = vbCharacters
Printer.CurrentX = 51
Printer.CurrentY = 41
Printer.Print "Here"

Printer.CurrentX = 31
Printer.CurrentY = 21
Printer.Print "Was"

Printer.CurrentX = 11
Printer.CurrentY = 1
Printer.Print "JRC Systems"

Printer.EndDoc

When you look at that page, it would somewhat resemble
     JRC Systems
                        was
                               here
even though we did not print the text in that order.

As far as changing Fonts and remaining on the same line, its as easy as a ";"
Printer.Print "123xyz";    
<<< having the ";" at the end of the line tells VB not to do a Carriage-Return/Line Feed.

Programmatically, you'd still want to issue a ".CurrentX =##" to get ready for the next column.
But you'd be on the same line.

When changing Fonts, you are typically safer to change them in this order.

Printer.Font.Name = "Barcode Font"
Printer.Font.Size = [your size]
Printer.Print "123456";

Printer.Font.Name = "Courier New"
Printer.Font.Size = 10
Printer.CurrentX = 25
Printer.Print "3";
etc

Also, due to a bug in VB, when you are dealing with Font Sizes that are small, typically 8 or less,
you need RESET the font-name after changing to a small font.

i.e.
Printer.Font.Name = "Bar Code"
Printer.Font.Size = 6
Printer.Font.Name = "Bar Code

Another common practice that is used is to make Font Variables, that contain the presets of your desired fonts.
Dim poFNTbarcode As New StdFont
poFNTbarcode.Name = "Bar Code"
poFNTbarcode.Size = 12

Set Printer.Font = poFNTbarcode

etc

This should definitely resolve your issues/Questions on Printers and Fonts.




0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 79
passing parameter in sql procedure 9 57
VBA Shell can't Find Word document 11 77
VB 6 error 5 in windows 10 but not in XP 7 46
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now