Results 1 to 9 of 9

Thread: Center text in a box to print[RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Resolved Center text in a box to print[RESOLVED]

    Hi to all:

    I would like print in a box a few lines of text but I want print this lines centering...
    VB have some instruction to do this?

    Thanks
    Last edited by sacramento; Oct 7th, 2007 at 05:06 PM.

  2. #2
    Addicted Member Vanasha's Avatar
    Join Date
    Jun 2007
    Location
    In a bin.>_>
    Posts
    152

    Re: Center text in a box to print

    I don't really know what this so called 'box' is.
    But in label control there is the property Align, this aligns text (Eg in centre). Is this what you want?
    Quote Originally Posted by Vanasha
    Sorry, i'm slow.


  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Center text in a box to print

    Hi:

    No...that property it's to appear in the screen...I want print!

  4. #4
    Addicted Member Vanasha's Avatar
    Join Date
    Jun 2007
    Location
    In a bin.>_>
    Posts
    152

    Re: Center text in a box to print

    Oh, printing to an object. Sorry I don't know.
    Quote Originally Posted by Vanasha
    Sorry, i'm slow.


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

    Re: Center text in a box to print

    to print to a form, in the center horizantal and vertical
    vb Code:
    1. printstr = "the string i want to print"
    2. form1.currentx = (form1.scalewidth - form1.textwidth(printstr)) /2
    3. form1.currenty = (form1.scaleheight - form1.textheight(printstr)) /2
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Center text in a box to print

    he forgot to put form1.print printstr
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Center text in a box to print

    Hi:

    Ok...this code print text center vertical and horizontal,but in the middle of a form...It's not exactly that I want to do!!!

    That I want to do is:

    1 - I Draw a box:
    Code:
    Printer.Line (700, 4600)-(5350, 7680), , B
    Now I want put text "The String I want to Print" in this box but centered.

    This is possible?

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

    Re: Center text in a box to print

    vb Code:
    1. printer.currentx = (5350-700 - printer.textwidth(printstr)) /2
    2. printer.currenty = (7680 - 4600 - printer.textheight(printstr)) /2
    3. printer.print printstr
    i think that should do it, but haven't tested
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Center text in a box to print

    ok,the code work!

    Thanks a lot

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