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

x
?
Solved

End of Page

Posted on 2003-11-18
5
Medium Priority
?
251 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:Cheri Sheffield
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:Cheri Sheffield
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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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 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…
Suggested Courses

876 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