Solved

Printing With tabs

Posted on 2001-06-26
9
157 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

803 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