Solved

Printing Barcode and text together in VB6

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

705 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

18 Experts available now in Live!

Get 1:1 Help Now