Home All Groups Group Topic Archive Search About
Author
8 Mar 2006 12:45 AM
JCP
Hi

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.

Author
8 Mar 2006 12:51 AM
Karl E. Peterson
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/
Author
8 Mar 2006 1:08 AM
JCP
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/
>
>
>
Author
8 Mar 2006 3:19 AM
Jeff Johnson [MVP: VB]
"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....
Author
8 Mar 2006 4:49 AM
JCP
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....
>
>
>
Author
8 Mar 2006 10:11 AM
Mike Williams
"JCP" <J**@discussions.microsoft.com> wrote in message
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?

The text will print at the centre of the page whatever paper size you are
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
Author
8 Mar 2006 1:07 PM
Larry Serflaten
"JCP" <J**@discussions.microsoft.com> wrote
>
> 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.


Did you try

    Printer.CurrentX = (4608 -  Printer.TextWidth(sRegisterName)) / 2
    Printer.Print sRegisterName


It is something just to get you thinking....

;-)
LFS
Author
8 Mar 2006 11:35 PM
Bob O`Bob
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...
Author
9 Mar 2006 1:24 AM
JCP
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...
>