Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB 6.0 printer how to align

Posted on 2016-09-18
6
Medium Priority
?
79 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 22
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 49

Accepted Solution

by:
Martin Liss earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Closing Comment

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

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 49

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

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!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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…
Loops Section Overview
Suggested Courses

610 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