 |
| VB How-To Ask your "How do I do this with VB?" questions in this forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 18th, 2004, 11:30 AM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
TextBox (Align Center) Problem on Printing
Hello Again,
I am having a problem with Printing a TextBox now. On the form the Text in the TextBox is aligned in the Center of the Box. However when I print the TextBox, The text is always aligned on the Left of the TextBox.
Is there anyway to have the Text inside the TExtBox aligned to the Center of the Box on PRiting?
Thanks
Mark
|
|

February 18th, 2004, 12:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
What do you mean by "when I print the textbox"? Do you mean that you open a report based on that form and the textbox is aligned left on the report? Or do you mean you're actually printing the form where the texbox resides?
If it's the first situation, i.e. you're opening a report, make sure the textbox in the report is aligned center. Having the form aligned center doesn't affect the report.
If it's the second situation, i.e. you're printing the form (File > Print), then DON'T! :D Unless you're doing a screen capture for your help manual, there is no reason you should ever print a form.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

February 18th, 2004, 02:18 PM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The way I am doing it it not doing a PrintForm. I have created a print module that say for e.g.
Printer.currentX = 240
Printer.CurrentY = 300
Printer.Print TextBox1.Text
In the Form the TextBox1 Align properter is set to vBCenter. On the Form at Runtime, The text in the Textbox is Centered.
When I click on PRint, The text is Justified Left.
I found a WorkAround in the meantime:
Printer.CurrentY = 2640
Printer.CurrentX = 240 + (100 * (MaxChar - Len(FormBonCommande.TextEcole.text)) / 2)
Printer.Font.Bold = True
Printer.Font.Size = 10
Printer.Print FormBonCommand.TextBox1.Text
'MaxChar is the Maximum Character that can be typed in the TextBox (here 44). 100 is the approximate size in Twips for 1 Character space. In order to have the text centered I want the same number of spaces on both sides of the text in the textbox therefore I divide / 2.
|
|

February 18th, 2004, 03:01 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
A better solution: *after* you set the right font to center justify use
Printer.Font. ... everything here
Printer.CurrentX = myCenterPosition - Printer.TextWidth(myTextBoxString) / 2
Printer.Print myTextBoxString
This take care of everything. To right justify, take the / 2 out
Marco
|
|

February 18th, 2004, 03:39 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Glad you found a solution around your problem, but now I'm totally lost. I don't know what you mean by, "I have created a print module." If you're printing the contents of a form, I assumed you're opening a report. I don't know what the code you presented actually does.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

February 18th, 2004, 05:30 PM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What I meant by I wrote the print module is:
I have a Menu on my Form which is Print. This calls my Print Procedure which will format the output that will come out of the printer.
i.e.
Print a Box around some text,
Place a Label at Printer.currentX and PRinter.CurrentY,
Do not print the Button that is on the Form.
In Fact, What my Print Procedure will do is do some sort of Me.PrintForm but in a Nicer Way.
That's it.
......
Marco thanks again for the better Solution.
Mark
|
|

February 18th, 2004, 05:46 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Quote:
quote:Originally posted by mrhyman
In Fact, What my Print Procedure will do is do some sort of Me.PrintForm but in a Nicer Way.
|
Ahhhhh, so you ARE printing a "snapshot" of your form. OK, now I know what you're doing. However, note that printing the form to get info is not recommended. The recommended way of getting info from your form on paper is to create a REPORT and print THAT.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

February 18th, 2004, 07:44 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Why so? If the data shown in the form is in sync with the real data (wherever it is) I do not see why you have to create a report.
Just curious.
Marco
Quote:
quote:Originally posted by SerranoG
Ahhhhh, so you ARE printing a "snapshot" of your form. OK, now I know what you're doing. However, note that printing the form to get info is not recommended. The recommended way of getting info from your form on paper is to create a REPORT and print THAT.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|
|

February 19th, 2004, 08:32 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Well, forms tend to waste a great deal of paper toner and space because the data on there is maximized for input, but not necessarily for reading or storing in a file cabinet on paper. Reports better organize data in ways that people can read them, they make better use of white space (saving on toner), and the often come up much cleaner than forms because you get just the data and no form elements. A well organized report is also more professional.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

February 19th, 2004, 12:14 PM
|
|
Authorized User
|
|
Join Date: Feb 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well Basically, I think I am creating my own report by writing the procedure instead of using a Report.
Me too I am just curious to see how a Report would tend to maximixe the output. I have never used report before and have always written the procedure to have the text aligned and sized according to me.
Thanks for the advices anyway.
Mark
|
|
 |