Solved

End of Page

Posted on 2003-11-18
5
242 Views
Last Modified: 2010-05-03
Newbie to experts exchange...my first question :)

I need some advice on reading the end of page from a text file.  I am working on a visual basic 6 program to convert some text files (output from another program) to pdf.  The conversion is going great but the report has pages with varying number of lines per page.  If I could detect the end of page than I can just force an end of page at that point.  Can’t remember how or if you can do this in VB6.  Any suggestions would be greatly appreciated.

Thank you
0
Comment
Question by:LambchopAZ
5 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 9774033
How are you running the conversion? Are you reading the text file or using some sort of a object to do a conversion?  If you are reading a text file a row at a time, you can check for a flag to let you know then to start a new page.

Leon
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9774153
I don't know where you're reading from, but if the incoming data is in standard ascii format then you want to watch for ascii code 12 (or 0C in hex) which signifies a page break / form feed.
0
 

Author Comment

by:LambchopAZ
ID: 9774155
Code below is how I am reading in the text file.  I am utilizing VSVIEW activex printer utility (ComponentOne).

 With vp                   'vp is the VSPrinter object
        .StartDoc
        Open FromPath & "\" & theFile For Input As #1
        Do While Not EOF(1)   ' Loop until end of file.
            Line Input #1, x
            .Paragraph = x
        Loop
        Close #1
        .EndDoc
    End With
   
If I understand correctly I could test the line input for an end of page flag?? How??

Cheri

0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9774255
You would need to parse the text of the line in the loop.  Assign  the line to a string variable and check for the character. Ideally the character you are looking for is the first one in the line.

Leon
0
 
LVL 15

Accepted Solution

by:
SRigney earned 250 total points
ID: 9774594
Modification to your code to look for End of page character.

With vp                   'vp is the VSPrinter object
        .StartDoc
        Open FromPath & "\" & theFile For Input As #1
        Do While Not EOF(1)   ' Loop until end of file.
            Line Input #1, x
            .Paragraph = x
            If InStr(1, x, Chr(12)) Then
               ' This is the end of page, need a new page.
            End If
        Loop
        Close #1
        .EndDoc
    End With
   
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now