Solved

Printing With tabs

Posted on 2001-06-26
9
158 Views
Last Modified: 2010-05-02
Printer.Print Suppcode; Tab; Desc; Tab; Format(!Nett, "#,##0.00"); Tab; bc;

this line of code prints out

12.we32
wall plug
12.00
5600165307432

i want this to appear on  one line of the printout.
like this
12.we32  wall plug          12.00  5600165307432


How do I do this?

***    *********************  ***  ********
**     **************         ***  ********
***    *******************    ***  ********
*****  *********************  ***  ********
***    *****************      ***  ********

if i use spc(n) i get this

***  *********************  ***  ********
**  *****************  ***  ********
***  *********************  ***  ********
*****  *********************  ***  ********
***  *****************  ***  ********




0
Comment
Question by:Eamon
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6227662
You have to use a non-proportional font if you use either of these methods. The width of a space is not the same as a character and this is why you get odd results. If you use the courier font for example which is mono-spaced (i.e., every character including spaces takes up the same amount of space - width & height) then you should see an improvement in the result. Also you should use vbTab as the seperator rather than TAB unless you have declared this and assigned it to the appropriate character (8). If you want more precise control over the position of the text even with proportional fonts then you can investigate the .CurrentX and .CurrentY properties which will allow you to specifically place the elements on the printed page.
0
 
LVL 1

Author Comment

by:Eamon
ID: 6227738
when i try
Printer.Font.Name = "courier"

it sets the font to "news gothic mt"

what's going on here?
0
 
LVL 1

Author Comment

by:Eamon
ID: 6227752
when i try
Printer.Font.Name = "courier"

it sets the font to "news gothic mt"

what's going on here?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:Eamon
ID: 6227765
when i try
Printer.Font.Name = "courier"

it sets the font to "news gothic mt"

what's going on here?
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6228247
The old way of printing in columns was to use either the tab character, tab function, or the comma.

For your line:

Printer.Print Suppcode; Tab; Desc; Tab; Format(!Nett, "#,##0.00"); Tab; bc;

I assume that Tab is defined as chr$(9) or vbTab (same thing).  How about trying:

Printer.Print Suppcode, Desc, Format(!Nett, "#,##0.00"), bc;

I haven't tried it, so it may result in the same proportional problems.  It also may mess up if consecutive lines are not in the same tab zone.

The tab function would be (as I recall):

Printer.Print Suppcode; Tab(10); Desc; Tab(40); Format(!Nett, "#,##0.00"); Tab(55); bc;
0
 

Expert Comment

by:mhowling
ID: 6230354
It could well be your version of VB or your printer thats at fault as when I try it in VB6 with a HP Laserjet 4 it appears to work fine.

Alternatively you could write a function to output text at a specified point on the page.  i.e.


Private Sub DrawText(X As Single, Y As Single, Text As String)
    Printer.CurrentX = X
    Printer.CurrentY = Y
    Printer.Print Text
End Sub

AND THEN CALL

DrawText 100,200, suppcode
DrawText 200,200, Desc
DrawText 300,200, Format(Nett, "#,##0.00"
DrawText 400,200, bc

(This could be done in a loop)
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6244738
If it wasn't good enough for better than a "C" grade why accept the comment as an answer without asking for more information. I could have easily improved my response if you had responded to the thread.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6249484
Eamon,
If the answer solved your problem, it deserves an "A".  If it got you in the right direction, maybe a "B".  If it was a bad work-around and you got no support, then maybe a "C"...but only with sufficient communication where you got no further help.

FYI
Some experts look at your grading history and will not assist those who offer "C" grades.  It not only impacts the expert receiving the grade, but also yourself!
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6249487
Eamon,
If the answer solved your problem, it deserves an "A".  If it got you in the right direction, maybe a "B".  If it was a bad work-around and you got no support, then maybe a "C"...but only with sufficient communication where you got no further help.

FYI
Some experts look at your grading history and will not assist those who offer "C" grades.  It not only impacts the expert receiving the grade, but also yourself!

P.S.
If you'd like to change the grade, add a zero-point question in the Customer Support topic area.
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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

856 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