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
Printable View
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
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.
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
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
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.
Pete, how does that virtual printer work? It wasted 3 pages of paper. What the heck is CUTE?
i did some testing after posting really couldn't see any noticable differenceQuote:
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.
p.
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.
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
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.