Results 1 to 10 of 10

Thread: Printing Alignment

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    3

    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

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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:
    1. Private Sub Command1_Click()
    2. Dim strAmount As String * 11
    3.  
    4.     [b]RSet[/b] strAmount = "12.50"
    5.     Debug.Print "$" & strAmount
    6.    
    7.     [b]RSet[/b] strAmount = "1,230.000"
    8.     Debug.Print "$" & strAmount
    9.  
    10. End Sub

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. Private Sub Command1_Click()
    2. Dim p As Printer, x As Integer, i As Integer
    3. For Each p In Printers    ' set printer to virtual driver to save on paper
    4.     If Not InStr(p.DeviceName, "Cute") = 0 Then Set Printer = p: Exit For
    5. Next
    6. With Printer
    7.     pspace = Printer.TextWidth("53,333.99")    ' set a width for maximum value
    8.     For i = 1 To 1000 Step 5
    9.         x = i & ".78"
    10.         Printer.Print "$";
    11.         .CurrentX = .CurrentX + pspace - .TextWidth(x)
    12.         Printer.Print x
    13.     Next
    14.     Printer.EndDoc
    15. End With
    16.  
    17. Exit Sub

    hope this helps pete

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Printing Alignment

    Pete, how does that virtual printer work? It wasted 3 pages of paper. What the heck is CUTE?

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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.

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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
  •  



Click Here to Expand Forum to Full Width