Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

End of Page

Posted on 2003-11-18
5
Medium Priority
?
250 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

730 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