Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not printing with proper font and size

Status
Not open for further replies.

WyoProgrammer

Technical User
May 13, 2005
25
0
0
US
I am having a problem printing in VB5. Using previous versions of VB I was able to tell the printer what font name and font size and it would consistently print as I wanted. I need to print in Courier New so I can create columnized printouts but in VB5, sometimes the printouts come out right and other times they print in a different font and size. I am using the commands:
Printer.Font.Name="Courier New"
Printer.Font.Size=12
Sometimes if I print 2 or more of the same form, the first prints properly but the others print out in a proportionally spaced font and don't look right. Any suggestions?
 
Hi WyoProgrammer
If the print out is consistent the first time round and only goes haywire in subsequent prints then it has to do with your code.
By first time, I mean that you have to ensure that there is nothing in the printer queue. Best bet is to delete any pending print jobs, switch off the printer and switch it on again before printing.
If you could post more of your code, I may be able to help out.
[bigcheeks]
 
DeltaTech,
It really is strange because there are some printouts that print with the wrong font up to a point and then switches to the font and size I requested. What I am doing is printing a table of the NFL games and I like the looks of it in a non-proportional font like Courier. If I tell it to print more than one copy of the table, sometimes the first one prints correctly but the subsequent tables are done in a different font. Below is an example of what I am doing.

Printer.Font.Size=12
Printer.Font.Name="Courier New"
Printer.Line (LeftSide,Top)-(RightSide,Bottom),black,B
Printer.CurrentY=1440
For I=1 to Games
Printer.Print Tab(10);Visitor$(I);
Printer.Print Tab(40);Home$(I)
Next
Printer.EndDoc

This should print a box with a list of the games for a certain week. Where I noticed it switched to the correct font and size was in one printout after I did a Printer.Font.Underline=True statement. I assumed that once you told the printer to print in a certain font and size, it would continue to do so until it received a command changing it. I have programmed quite a bit in VB3 and it always works that way. I could put a Printer.FontName="Courier" at the beginning of the program and all my printouts would be in that font. Thanks for any assistance you can give. This is a very frustrating problem as I am writing a program to keep track of an office football pool and need the printouts to look nice.
 
Hi WyoProgrammer
I know it seems a bit odd to do this but, try issuing the font command within the For Next loop:
Code:
Printer.Line (LeftSide,Top)-(RightSide,Bottom),black,B
Printer.CurrentY=1440
For I=1 to Games     
     Printer.Font.Size=12
     Printer.Font.Name="Courier New"
     Printer.Print Tab(10);Visitor$(I);
     Printer.Print Tab(40);Home$(I)
Next
Printer.EndDoc
I have not used VB3, but I have gone through the same inconsistent results when using the printer command within VB5 and VB6, and had to make do with something like the above code. Even the Tab and Space commands did not always work as expected, and I use CurrentX to position it more consistently.
Anyway, hope this helps.
[bigcheeks]

 
DeltaTech,
That is the same thing that came to my mind and I tried that and it would work most of the time for multiple copies but then if I tried a different printout, it would be wrong. Here is something that I have most recently tried and it works even better but I am having trouble occasionally. I was hoping that this might be a simple solution from a more experienced programmer. Thanks for your help with this but looks like it will be an ongoing problem.

I set this statement when the program fist loads:

Dim X As New StdFont
X.Size = 12
X.Name = "Courier New"
Set Printer.Font = X

Then when I want to call a print routine I do this:

Printer.Font = X
Printer.Font.Size=12
Printer.Font.Name="Courier New"
Call PrintPicks()

This in fact works most of the time but I get an occasional incorrect printout. This has been and probably will continue to be a huge frustration! I appreciate your input!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top