Solved

End of Page

Posted on 2003-11-18
5
243 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now