×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VB Print preview

VB Print preview

VB Print preview

(OP)
I have written the following VB code(simplified) for printing output summary of a program that I have written, what I like to do is to be able to preview the output before it actually prints to the printer. Can anybody help me out??? Thanks you

Private Sub CmdPrint_Click()
    
    Cust = txtName.Text
    CustRef = txtCustRef.Text
    Proj = txtProj.Text
    Engr = txtEngr.Text
    Offer = txtOffer.Text
    Job = txtJob.Text
    sFileName = txtFile.Text
    
    Printer.ScaleMode = 5
    dXOffSet = (Printer.Width / 1444 - Printer.ScaleWidth) / 2
    dYOffSet = 5 / 16
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 1 - dYOffSet
    Printer.DrawWidth = 10
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.Line -(Printer.CurrentX, Printer.CurrentY + 9.5)
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 1 - dYOffSet
    Printer.Line -(Printer.CurrentX, Printer.CurrentY + 9.5)
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 1.725 - dYOffSet
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 1.75 - dYOffSet
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
        
    Printer.CurrentX = 6 - dXOffSet
    Printer.CurrentY = 1.75 - dYOffSet
    Printer.Line -(Printer.CurrentX, Printer.CurrentY + 1)
    
    Printer.CurrentY = 0.75 - dYOffSet
    Printer.FontName = "Times New Roman"
    Printer.FontSize = 18
    Printer.Print Tab(25); "DESIGN & SIZING INFORMATION"
    Printer.FontSize = 12
    Printer.Print Tab(50); "WITH ALL THE TRIMMINGS"
    Printer.FontSize = 9
    Printer.Print Tab(72); "By: Authors"
    Printer.FontSize = 10
    Printer.CurrentX = 1.1 - dXOffSet
    Printer.CurrentY = 1.8 - dYOffSet
    Printer.Print "CLIENT :"; Tab(35); Cust; Tab(105); "DESIGNED BY :"; Tab(125); Engr
    Printer.DrawWidth = 1
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 2 - dYOffSet
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.CurrentX = 1.1 - dXOffSet
    Printer.CurrentY = 2.05 - dYOffSet
    Printer.Print "REFERENCE :"; Tab(35); CustRef; Tab(105); "OFFER NO. :"; Tab(125); Offer
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 2.25 - dYOffSet
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.CurrentX = 1.1 - dXOffSet
    Printer.CurrentY = 2.3 - dYOffSet
    Printer.Print "PROJECT :"; Tab(35); Proj; Tab(105); "JOB NO. :"; Tab(125); Job
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 2.5 - dYOffSet
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.CurrentX = 1.1 - dXOffSet
    Printer.CurrentY = 2.55 - dYOffSet
'    Printer.Print Tab(105); "FILE NO. :"; Tab(125); File
    Printer.Print "DESIGN BY :"; Tab(35); Engr; Tab(105); "FILE NO. :"; Tab(125); sFileName
    
    Printer.CurrentX = 1 - dXOffSet
    Printer.CurrentY = 2.75 - dYOffSet
    Printer.DrawWidth = 10
    Printer.Line -(Printer.CurrentX + 7, Printer.CurrentY)
    Printer.CurrentY = 2.6 - dYOffSet
    Printer.FontSize = 11
    Printer.FontBold = True
    Printer.Print Tab(50); "PROCESS DESIGN CONDITIONS"
    Printer.FontBold = False
        
    Printer.EndDoc
End Sub
Replies continue below

Recommended for you

RE: VB Print preview

Hi,

In the past I've done with a picture box on a form and then printed to the picture box control.

Picture1.Cls
Picture1.Print "JOB NAME"
Picture1.Line (0, 0)-(30, 0)

You get the idea.

Hope that helps

RE: VB Print preview

Dim OutputPRN as Object
'change all your statements to use this object instead
'   Printer.FontSize = 11
'  becomes
'   OutputPRN.FontSize = 11
'
'At the begining of your routine, query

Private Sub CmdPrint_Click()
if PrintPreviewFlag Then _
 Set OutputPRN = Picture1 _
 Else _
 Set OutputPRN = PRINTER

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close