Solved

VB 6.0 printer how to align

Posted on 2016-09-18
6
49 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:irietek
  • 3
  • 2
6 Comments
 
LVL 19
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:irietek
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 45

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Closing Comment

by:irietek
ID: 41804882
good example
0
 
LVL 45

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 45

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now