Solved

VB Print Problems Again

Posted on 2003-10-24
3
346 Views
Last Modified: 2012-05-04
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
Comment
Question by:jake67
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
TomLaw1999 earned 125 total points
ID: 9651373
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
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9651518
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
 

Author Comment

by:jake67
ID: 9674049
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question