Solved

Printing Barcode and text together in VB6

Posted on 2006-07-21
2
1,679 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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