Solved

Printing Barcode and text together in VB6

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

828 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