Solved

Printing Barcode and text together in VB6

Posted on 2006-07-21
2
1,717 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

623 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