Solved

End of Page

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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
Course of the Month8 days, 21 hours left to enroll

617 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