Solved

VB 6.0 printer how to align

Posted on 2016-09-18
6
71 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 20
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 47

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 47

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 47

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
BATCH to EXE Converter 2 70
Do Wend Macro not working 22 58
Crashing when deleting value with no child in Binary Tree 4 31
"lblTime is not declared" 3 34
This is about my first experience with programming Arduino.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

749 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