Link to home
Start Free TrialLog in
Avatar of Simon Chen
Simon ChenFlag for Canada

asked on

VB 6.0 printer how to align

hi,

if I need to use VB 6.0 printer.print function to print like this with POS printer, how can I make QTY Description left align, and Price Right Align?
i have tried use space to make the price right align, but it didn't work.
thanks


QTY   DESCRIPTION     PRICE
   1      myinfo                  $9.20
   2      myinfo2             $19.30
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

>tried use space to make the price right align, but it didn't work.

for that to work properly, each character needs to take the same space so a mono-spaced font such as Courier needs to be used
Avatar of Simon Chen

ASKER

how to make it as same space?

here is what I have done:

Chdetail = QTY + Detial, less than 18 then add " " ,and finally add price.

For DetailLen = 1 To 18 - Len(ChDetail)
 chdetail1 = ChDetail + " "
                                     
Next DetailLen

Chdetail1=chdetail1+ price
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
good example
You could modify the above to print the numbers as String (you might have to use CStr() )

Const COL1 = 1000
Const COL2 = 2500
Const COL3 = 5000

Printer.CurrentX = COL1
Printer.Print "QTY";
Printer.CurrentX = COL2
Printer.Print "DESCRIPTION";
Printer.CurrentX = COL3 - Printer.TextWidth("PRICE")
Printer.Print "PRICE"

Printer.CurrentX = COL1
Printer.Print "1";
Printer.CurrentX = COL2
Printer.Print "myinfo";
Printer.CurrentX = COL3 - Printer.TextWidth("$9.20")
Printer.Print "$9.20"

Printer.CurrentX = COL1
Printer.Print "2";
Printer.CurrentX = COL2
Printer.Print "myinfo2";
Printer.CurrentX = COL3 - Printer.TextWidth("$19.30")
Printer.Print "$19.30"

Open in new window

Thanks and I'm glad I was able to help.

Expand my profile’s “Full Biography” and you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2016
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2015