Click to See Complete Forum and Search --> : printer object alignment
Cyrus
September 13th, 2001, 01:10 AM
how can I aligned printing of numbers from left-justified to right-justified ;
vValue1=xxx.xx
vValue2=xxxx.xx
vValue3=xx.xx
Printer.print "Value No 1 : " & vValue1
Printer.print "Value No 2 : " & vValue2
Printer.print "Value No 3 : " & vValue3
results
Value No 1 : xxx.xx
Value No 2 : xxxx.xx
Value No 3 : xx.xx
thanks
cyrus
Cimperiali
September 13th, 2001, 02:33 AM
You may set the currentx property of printer:
http://codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=26234&page=&view=&sb=
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Cimperiali
September 13th, 2001, 02:34 AM
Another trick: store numbers in string variable of fixed lenght, aligned to right with format function. Then print the string variables.
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Cakkie
September 13th, 2001, 03:30 AM
As Cimperiali implied, you will have to use the CurrentX property. Then, in assosiation with the TextWidth, you can determine where to start. Note tha in the code I used Me instead of Printer, which results in the text being printed on the form.
Dim sWidth as Long
' compute point where it must be alligned, you can give this a fixed value if you want
sWidth = me.TextWidth("000000.00")
me.CurrentX = sWidth - me.TextWidth("1234.56")
me.print "1234.56"
me.CurrentX = sWidth - me.TextWidth("123.45")
me.print "123.45"
me.CurrentX = sWidth - me.TextWidth("12345.67")
me.print "12345.67"
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Cyrus
September 17th, 2001, 12:46 AM
excellent, but I left one major issue ,a text preceeded the numbers
ie
vGross=123.45
vDiscount=23.45
vNett=100.00
printer.currentx = sWidth - printer.textwidth(vGross)
printer.print "Gross : " & vGross
printe.currentx=swidth - printer.textwidht(vDiscount)
printer.print "Discounts : " & vDiscount
printer.print " ----------------- "
printer.currentx=swidth - printer.textwidht(vNett)
printer.print "Nett : " & vNett
using Currentx affects alignment of text
thanks in advance
cyrus
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.