Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

VB Print Problems Again

I'm doing a simple print out of text and I cannot get the left margin to work (using Printer.CurrentX = 1440).  I can move the text down with Printer.CurrentY but cannot move it in from the left.  (see code)  Incidentally, the CurrentY moves the text down about 2 inches, not the 1 inch I expected for 1440 twips.  Why?

Also, I defined the Greek letter, nu, as ChrW$(957) in my code, but it won't print with the code below.  I get a '?' on the printout where the nu should be.  The nu letter is in the lbl1resultCaption:

Dim nu As String
nu = ChrW$(957)
lblResult1Caption.Caption = "Liquid " & nu & " (ft" & super3 & "/lbm)"

This is the printer code:

PrinterDefault = True
   
    Printer.PaperSize = vbPRPSLetter
    Printer.FontName = "TimesRoman"
    Printer.FontSize = 12
    Printer.CurrentX = 1440
    Printer.CurrentY = 1440
    Debug.Print
    Debug.Print "Printer.CurrentX = " & Printer.CurrentX
    Debug.Print "Printer.CurrentY = " & Printer.CurrentY
   
    Printer.Print
    Printer.Print lblProductName
    Printer.Print lblCopyright
    Printer.Print lblVersion
   
    Printer.Print
    Printer.Print "Pressure (psia) = " & txtPressure.Text
    Printer.Print "Temperature (degrees F) = " & txtTemperature.Text
    Printer.Print
    Printer.Print "Tsat (degrees F) = " & lblOutTsatValue.Caption
    Printer.Print "Tmetastable (degrees F) = " & lblOutTmetaValue.Caption
    Printer.Print
   
    If lblResult1.Visible = True Then
        Printer.Print lblResult1Caption & " = " & lblResult1
    End If
    If lblResult2.Visible = True Then
        Printer.Print lblResult2Caption & " = " & lblResult2
    End If
    If lblResult3.Visible = True Then
        Printer.Print lblResult3Caption & " = " & lblResult3
    End If
    If lblResult4.Visible = True Then
        Printer.Print lblResult4Caption & " = " & lblResult4
    End If
    If lblResult5.Visible = True Then
        Printer.Print lblResult5Caption & " = " & lblResult5
    End If
    If lblResult6.Visible = True Then
        Printer.Print lblResult6Caption & " = " & lblResult6
    End If
    Printer.EndDoc

Thanks, Jake67
0
jake67
Asked:
jake67
  • 2
1 Solution
 
TomLaw1999Commented:
Hi Jake

There is a problem with your code. Setting the currentX value will only set a margin for the next line printed i.e. if you try to print a second line it will move to the left.

To overcome this you need to set the currentx value before printing each value. For example

printer.currentx =  1440
printer.print "Hello"
printer.currentx=1440
printer.print "World"

The only alternative to this is to use the semicolon ';' after each printed value. This works by surpressing the line feed thereby keeping the printer on the current line e.g

printer.currentx =  1440
printer.print "Hello";
printer.print "World"


0
 
TomLaw1999Commented:
Your Greek letter nu, not totally sure about this one but it could be because the font set that you are using i.e. Arial or Times New Roman does not support Greek letters (do you have a Greek font set installed). The font can be changed with the command:

 Printer.fontname = "Fontname"
0
 
jake67Author Commented:
Thanks, Tom.

The explanation of currentX setting only the margin for the next line was right on.  As to the Greek letter, nu, I'll have to work on that.  I can get it to display properly on the screen, but not print.

Jake
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now