?
Solved

Printing Problem using VB

Posted on 2003-03-04
4
Medium Priority
?
177 Views
Last Modified: 2010-05-18
Hi, guys,

What I need to do is like a check printing job, i want to pull out information from database, then fill those information into some type of format, then print it with specified check papers, which is 3 checks per page.

I try to use the scanned check as the background image of the VB Form to make those line aligning and formating issues much easier. The problem is, the largest height of a Form is 12288, which is smaller than a letter size paper.
when i use the Form1.PrintForm method, it can't fit the letter size paper.

Can i increase the height of a Form, or is there other way to print a well-organized page from a Form?

I tried some other ways also:
1. I tried to output all infomation into a plain text file, then print it. The problem is then i can't insert a picture of company logo in the text file, and the formating is really a pain.

2. I tried to use the Printer object, which is like:

Printer.Font = "Arial"
Printer.FontSize = 10
Printer.Print Tab(10); "a"; Tab(30); "b"; Tab(50); "c"
Printer.EndDoc

This allows me not worry about the height of a form, nor the picture printing issue. However, it gave me a real hard time to align the info to the pre-specified column, it might print on the lines, not above it.
Anyway to have better control on Printer object? For example, specify the line spacing?

3. I saw there is an example in MSDN network called "Tip 100: Printing a Form Multiple Times on One Page"
the link is as follows
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvbtips/html/msdn_msdn100.asp

I feel like it's the solution for me, cause i need to print 3 checks a page. Unfortunately, even I copied the code and followed the instructions, the program ended up with "Run-time Error '6': Overflow" at the line of
"X = SetStretchBltMode(Form2.hDC, 3)", which i have no idea what is that all about.

Sorry for this long question. Hope this beginner question won't take too much of your time. I just tried any possible way to get my work done. Any help, any approach will be a big help to me.

Thanks!!

Will
0
Comment
Question by:WillatSA
[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
4 Comments
 
LVL 2

Accepted Solution

by:
JoaTex earned 200 total points
ID: 8068542
Hi

This is a litle example where you can have control on left and right margins, and space between lines, With top Name. Try and adapted to your needs.

Code:
Option Explicit
Dim Provis As String    'String Text1
Dim N                   'Counter
Dim LeftSide            'Margin Left
Dim RightSide           'Margin Right
Dim TopSide             'Top Title Position
Dim Spac                'Space between Lines
Dim BottomSide          'Position Ens Page
Dim Position            'Flag Control New Line

Private Sub PrintCmd_Click()
    LeftSide = 1000
    RightSide = 9000
    Spac = 250
    BottomSide = 15000
    Title                  'Title
    Provis = Text1.Text     'Transfer Text1
    For N = 1 To Len(Provis)    'Run Each Character of String
    Printer.Print Mid(Provis, N, 1);    'Print Character
    If Printer.CurrentY > Position + 32 And Mid(Provis, N, 1) <> Chr(13) Then 'Control CRLF
        Printer.CurrentX = LeftSide
        Printer.CurrentY = Position + Spac  'New Line
        Position = Printer.CurrentY
    End If
    If Printer.CurrentX > RightSide And Mid(Provis, N, 1) = " " Then 'Control End Line
        Printer.CurrentY = Position + Spac  'New Line
        Position = Printer.CurrentY
        Printer.CurrentX = LeftSide     'Control Left Margin
    End If
    If Printer.CurrentY > BottomSide Then   'Control End Page
        Printer.NewPage
        Title
    End If
    Next N
    Printer.EndDoc      'Close Print Document
End Sub

Private Sub Title()
    TopSide = 2000
 Printer.FontName = "Arial Black"      'Config Title
    Printer.FontSize = 14
    Printer.FontBold = True
    Printer.CurrentY = TopSide     'Position Title
    Printer.CurrentX = LeftSide + 3000
    Printer.Print "Print Text Box"
    Printer.FontName = "Arial"
    Printer.FontSize = 12       'Change Size Plain Text
    Printer.FontBold = False
    Printer.CurrentY = TopSide + 1000
    Position = Printer.CurrentY
    Printer.CurrentX = LeftSide     'margin LeftSide Size
End Sub
0
 
LVL 3

Expert Comment

by:DocM
ID: 8068555
It should be a simple matter to layout the check on the page using VB's printer object (i.e. Printer.CurrentX, Printer.CurrentY, Printer.Print, etc.).
0
 

Author Comment

by:WillatSA
ID: 8072672
thanks, i am now working with the printer object... though it's really a print-and-error process.
0
 

Expert Comment

by:CleanupPing
ID: 8900691
WillatSA:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 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