Solved

VB 6.0 printer how to align

Posted on 2016-09-18
6
74 Views
Last Modified: 2016-09-19
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
0
Comment
Question by:Simon Chen
[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
  • 3
  • 2
6 Comments
 
LVL 21
ID: 41804235
>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
0
 

Author Comment

by:Simon Chen
ID: 41804767
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
0
 
LVL 48

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 41804835
You can use Printer.CurrentX to solve your problem without using a mono-spaced font.

Dim curValue As Currency
Const COL1 = 1000
Const COL2 = 2500
Const COL3 = 5000

Printer.CurrentX = COL1
Printer.Print "QTY";
Printer.CurrentX = COL2
Printer.Print "DESCRIPTION";
' Adjust this line to get "PRICE" where you want it
Printer.CurrentX = COL3 - Printer.TextWidth("PRICE")
Printer.Print "PRICE"

Printer.CurrentX = COL1
Printer.Print "1";
Printer.CurrentX = COL2
Printer.Print "myinfo";
curValue = 9.2
Printer.CurrentX = COL3 - Printer.TextWidth(curValue)
Printer.Print Format(curValue, "$.00")

Printer.CurrentX = COL1
Printer.Print "2";
Printer.CurrentX = COL2
Printer.Print "myinfo2";
curValue = 19.3
Printer.CurrentX = COL3 - Printer.TextWidth(curValue)
Printer.Print Format(curValue, "$.00")

Open in new window

1
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:Simon Chen
ID: 41804882
good example
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 41804883
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

0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 41804887
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

717 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