|
-
Jan 14th, 2005, 10:42 PM
#1
Thread Starter
New Member
Printing Alignment
I am learnig VB, No matter what I do, I can not get the right Format to get a nice looking printout. "Currency" aligns the Dollar signs in a column, not the points. For example,
$12.50
$1,230.00
Please help, I am going crazy,
Thanks
Luis
-
Jan 14th, 2005, 11:16 PM
#2
Re: Printing Alignment
where are you outputting to? printing is not easy in VB. there are a few things that you can do, depending on where you are outputting formatted data.
-
Jan 14th, 2005, 11:20 PM
#3
Re: Printing Alignment
Actually it is quite easy - the problem is the following statements are very little documented: RSet to align right and LSet - left.
VB Code:
Private Sub Command1_Click()
Dim strAmount As String * 11
[b]RSet[/b] strAmount = "12.50"
Debug.Print "$" & strAmount
[b]RSet[/b] strAmount = "1,230.000"
Debug.Print "$" & strAmount
End Sub
-
Jan 14th, 2005, 11:27 PM
#4
Re: Printing Alignment
i assume by printout you are referring to printer
this code will align the decimal , there maybe some slight variation if you are not using a fixed width font, particularly with .11, 1s are narrower than other charcacters
VB Code:
Private Sub Command1_Click()
Dim p As Printer, x As Integer, i As Integer
For Each p In Printers ' set printer to virtual driver to save on paper
If Not InStr(p.DeviceName, "Cute") = 0 Then Set Printer = p: Exit For
Next
With Printer
pspace = Printer.TextWidth("53,333.99") ' set a width for maximum value
For i = 1 To 1000 Step 5
x = i & ".78"
Printer.Print "$";
.CurrentX = .CurrentX + pspace - .TextWidth(x)
Printer.Print x
Next
Printer.EndDoc
End With
Exit Sub
hope this helps pete
-
Jan 14th, 2005, 11:28 PM
#5
Re: Printing Alignment
I never saw that before. Slick. I was using double formats earlier, but it looks like I'll be changing it again. The only problem is proportional fonts.
-
Jan 14th, 2005, 11:36 PM
#6
Re: Printing Alignment
Pete, how does that virtual printer work? It wasted 3 pages of paper. What the heck is CUTE?
-
Jan 14th, 2005, 11:36 PM
#7
Re: Printing Alignment
I never saw that before. Slick. I was using double formats earlier, but it looks like I'll be changing it again. The only problem is proportional fonts.
i did some testing after posting really couldn't see any noticable difference
p.
-
Jan 15th, 2005, 03:11 AM
#8
Re: Printing Alignment
my double-format works if the numbers are similar, but if one is 8 digits, and the other is 4, then they are way off. also, using non-proportional font messes things up, but courier 10 is too big for my listbox. I'm satisfied with the way it is, I worked pretty long on it again, after deciding to leave it. it's just that I had luck lining up the printout, so I thought that I would try it again. Bells and Whistles, don't ya know. The program is getting to be complete, ready for beta.
-
Jan 15th, 2005, 03:22 AM
#9
Re: Printing Alignment
hi david
missed your post before, think we must have both posted at the same time.
i use cutepdf writer for all my non printing works a treat and is free
cute pdf
i haven't had to do decimal tabbing for ages, had problems with it in printing and also printing RTF files which support decimal tab, but VBs implementation doesn't
i zoomed up the print i did in an extra test using different values for the cents i couldn't pick a difference to the decimal position even when it was 11 cents
if the values are higher just need to increase the dummy amount to get a space fron the $ sign
pete
-
Jan 15th, 2005, 03:28 AM
#10
Re: Printing Alignment
I see. I don't know if I want my customers to be using it. I thought that there was a way to print to a form for a preview that was easy to go back and modify the code that is currently used to print directly to the printer.
I wouldn't mind letting them have a preview before they print it out, and for half of the rtf's they have the option. I'll check it out tomorrow.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|