Spc/Tab, Printer object 
Author Message
 Spc/Tab, Printer object

According to VB documentation:

"the width of space characters printed using the Spc function is always an
average of the width of all characters in the point size for the chosen
font"

How do I find out this 'average width' of the current font on the printer
object?

My first, and obvious attempt is:

'
Private Function fnCurrentFontAVCharachterWidth() As Single

    Dim strAllChars As String
    Dim intCtr As Integer

    For intCtr = 0 To 255
        strAllChars = strAllChars & Chr(intCtr)
    Next intCtr

    fnCurrentFontAVCharachterWidth = Printer.TextWidth(strAllChars) / 256

End Function
'

But this does not seem to produce the required results, as if the whole
character set is not taken into consideration.

If only life was as easy as sngAvWidth = Printer.TextWidth(spc(1)) but it is
not!!

Any ideas?

Regards.



Sat, 17 Apr 2004 18:30:19 GMT  
 Spc/Tab, Printer object
I have just found an solution/example:

alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
AvgCharWidth = (Me.TextWidth(alphabet) / screen.TwipsPerPixelX)  / 52

Perhaps the VB doco's should read:

"average of the width of all alpha-characters"

and NOT

"average of the width of all characters"!!!

Perhaps the VB documentation should state that the font

Quote:
> According to VB documentation:

> "the width of space characters printed using the Spc function is always an
> average of the width of all characters in the point size for the chosen
> font"

> How do I find out this 'average width' of the current font on the printer
> object?

> My first, and obvious attempt is:

> '
> Private Function fnCurrentFontAVCharachterWidth() As Single

>     Dim strAllChars As String
>     Dim intCtr As Integer

>     For intCtr = 0 To 255
>         strAllChars = strAllChars & Chr(intCtr)
>     Next intCtr

>     fnCurrentFontAVCharachterWidth = Printer.TextWidth(strAllChars) / 256

> End Function
> '

> But this does not seem to produce the required results, as if the whole
> character set is not taken into consideration.

> If only life was as easy as sngAvWidth = Printer.TextWidth(spc(1)) but it
is
> not!!

> Any ideas?

> Regards.



Sat, 17 Apr 2004 18:37:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Controlling Text output to screen using TAB or SPC

2. Anomaly: Tab with the Printer object

3. Statistical Process Control (SPC) Function

4. Trying to use SPC function, nested

5. Line spc Smith Corona?

6. Printer Object - Getting the available printer information

7. VBA: Printer Object / Printer Collection

8. SPC custom control/activex needed for VB 5.0 prog

9. Printer object and printer fonts

10. bug sending text to printer via printer object

11. printer control object - cannot send Esc character to printer

12. Printer object can't print to network printer

 

 
Powered by phpBB® Forum Software