|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Center text with PRINTHi
I create a POS application with VB6. All works fine but there is something that I wa not be able to do. For print receips (tickets) I use the PRINT method, for products line there are no problems with aligment but in header all text just go to left. For example bussines name, address and other values are user defined, so I don't know if Name will be 30 characters o 78 for example. Do you know some method to center the value and pass to the PRINT method. Thanks in advance. JCP wrote:
> Do you know some method to center the value and pass to the PRINT .CurrentX = (.ScaleWidth - .TextWidth(MyText)) / 2> method. Hi
Thanks, I will test this idea. Kindest regards Show quoteHide quote "Karl E. Peterson" wrote: > JCP wrote: > > Do you know some method to center the value and pass to the PRINT > > method. > > .CurrentX = (.ScaleWidth - .TextWidth(MyText)) / 2 > > -- > Working without a .NET? > http://classicvb.org/ > > > "JCP" <J**@discussions.microsoft.com> wrote in message Great. When you're done with this test, let us know if the principles of news:CAC0A0E8-DABD-4FCC-889C-27E149D9225E@microsoft.com... >> > Do you know some method to center the value and pass to the PRINT >> > method. >> >> .CurrentX = (.ScaleWidth - .TextWidth(MyText)) / 2 > Thanks, I will test this idea. mathematics have changed, because that's the only way the code above will fail.... Karl, Jeff
The problem are not mathematics, my skill to program are the problem. I use this: Printer.CurrentX = (Printer.ScaleWidth - Printer.TextWidth(sRegisterName)) / 2 Printer.Print sRegisterName Works but... I get something not planned. The text centers exactly as you indicate me. But know I got a new problem. Or maybe is just my lack of experience I will use this to print tickets. A ticket usually is 3.2 inch wide. As I only have a laser printer, just the text centers but to a letter witdh. I can asume that if the user uses a ticket printer, the text will be centered correctly or How can I pass the Width to the printer? I try Printer.Width = 4608 and the system does not want to accept this. For all purposes, thanks for you help, your code it's exactly what I want. JCP Show quoteHide quote "Jeff Johnson [MVP: VB]" wrote: > > "JCP" <J**@discussions.microsoft.com> wrote in message > news:CAC0A0E8-DABD-4FCC-889C-27E149D9225E@microsoft.com... > > >> > Do you know some method to center the value and pass to the PRINT > >> > method. > >> > >> .CurrentX = (.ScaleWidth - .TextWidth(MyText)) / 2 > > > Thanks, I will test this idea. > > Great. When you're done with this test, let us know if the principles of > mathematics have changed, because that's the only way the code above will > fail.... > > > "JCP" <J**@discussions.microsoft.com> wrote in message The text will print at the centre of the page whatever paper size you are news:DE45172F-A7E5-4153-AF1F-9191B154DAB2@microsoft.com... > I use this: > Printer.CurrentX = (Printer.ScaleWidth - > Printer.TextWidth(sRegisterName)) / 2 > Printer.Print sRegisterName > I will use this to print tickets. A ticket usually is 3.2 inch wide. > As I only have a laser printer, just the text centers but to a letter > witdh. I can asume that if the user uses a ticket printer, the text > will be centered correctly or How can I pass the Width to the > printer? using provided that the paper actually in use matches the papersize set on the printer, which you always have to assume will be the case, so it will centre correctly on your 3.2 inch wide ticket printer with no problems. That is why Printer.ScaleWidth forms part of the equation in the above code. Don't worry about it. Karl's code will work fine. Mike "JCP" <J**@discussions.microsoft.com> wrote Did you try> > I use this: > > Printer.CurrentX = (Printer.ScaleWidth - Printer.TextWidth(sRegisterName)) / 2 > Printer.Print sRegisterName > > I try Printer.Width = 4608 and the system does not want to accept this. Printer.CurrentX = (4608 - Printer.TextWidth(sRegisterName)) / 2 Printer.Print sRegisterName It is something just to get you thinking.... ;-) LFS JCP wrote:
> Hi Yeah, I've done that a few times.> > I create a POS application with VB6. Though I'm usually not very proud of them. Oh! Wait! You meant "point of sale" didn't you? nevermind... Thanks to all for you help and support.
JCP, God bless you every day. Show quoteHide quote "Bob O`Bob" wrote: > JCP wrote: > > Hi > > > > I create a POS application with VB6. > > > > Yeah, I've done that a few times. > Though I'm usually not very proud of them. > > > Oh! Wait! You meant "point of sale" didn't you? > > > nevermind... >
What line does the error start on?
Setting background in vscrollbar to gray Help with trim! Searching a string How many ActiveX processes can I have? Visual BASIC has encountered a problem ... ADODC control - form settings to open the xcel sheet My screen stays on background GetSystemTime or GetLocalTime |
|||||||||||||||||||||||