I have a problem regarding the Printer object.
I have a simple line of code that prints a string on the left hand side of a page, a title in the centre and another string right jutified.
To right justify the third string I have identified the
width of the text using the Printer.Textwidth(string)
method. Trouble is, it doesn't work even though my VB book says it does. The right justified string is truncated
at the edge of the page, in other words the X position is to far to the right.
The code is as follows but I don't get why it isn't working.
Printer.FontName = "Courier New"
Printer.FontSize = "12"
Printer.Print vbCrLf
Printer.Print "Left justified String";
'
' Title Centered
Printer.FontUnderline = True
strMyLine = "My Header"
Printer.CurrentX = Printer.Width / 2
Printer.CurrentX = (Printer.CurrentX - _
Printer.TextWidth(strMyLine) / 2)
Printer.Print strMyLine;
Printer.FontUnderline = False
'
' Right Justified
strMyLine = "12345678901234567890"
Printer.CurrentX = Printer.Width - _
Printer.TextWidth(strMyLine)
Printer.Print strMyLine;
Printer.EndDoc
The right justified text is printed as '123456789012345'
missing the last '67890'.
Wierd.
Dazed and confused
I have a simple line of code that prints a string on the left hand side of a page, a title in the centre and another string right jutified.
To right justify the third string I have identified the
width of the text using the Printer.Textwidth(string)
method. Trouble is, it doesn't work even though my VB book says it does. The right justified string is truncated
at the edge of the page, in other words the X position is to far to the right.
The code is as follows but I don't get why it isn't working.
Printer.FontName = "Courier New"
Printer.FontSize = "12"
Printer.Print vbCrLf
Printer.Print "Left justified String";
'
' Title Centered
Printer.FontUnderline = True
strMyLine = "My Header"
Printer.CurrentX = Printer.Width / 2
Printer.CurrentX = (Printer.CurrentX - _
Printer.TextWidth(strMyLine) / 2)
Printer.Print strMyLine;
Printer.FontUnderline = False
'
' Right Justified
strMyLine = "12345678901234567890"
Printer.CurrentX = Printer.Width - _
Printer.TextWidth(strMyLine)
Printer.Print strMyLine;
Printer.EndDoc
The right justified text is printed as '123456789012345'
missing the last '67890'.
Wierd.
Dazed and confused