Solved

Reading from file help

Posted on 2004-03-25
3
182 Views
Last Modified: 2010-05-01
I have some code:

    Open FileName For Input As #1
    Do While (Not EOF(1))
        Input #1, TextIn
        If (Left(TextIn, 9) = "(%%[Page:") Then
            count = count + 1
        End If
    Loop
    Close #1
    MsgBox count

It was working great until it ran into a certain file.  I narrowed the problem down to this.  If the file looks like this:

(%%[Page: 1]%%) =
%%PageTrailer

Count becomes 1, however if the file looks like this:

"
(%%[Page: 1]%%) =
%%PageTrailer

Count remains 0.  This is a problem, as some of these files can be up to 5 mb and I have no way of controlling where quotation marks are in the file, as it is a print job in postscript format.  Is there some way I can tell me program to ignore the damn quote?  Or is there another way to read the file as a whole, not line by line, and search for the number of instances?

Thanks for all your help.

Dereck

0
Comment
Question by:Dereck21
3 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10682209
Try
   Line Input #1, TextIn
instead of
   Input #1, TextIn

Idle_Mind
0
 
LVL 11

Accepted Solution

by:
YohanShminge earned 150 total points
ID: 10682222
If you narrow that down a bit, it will work fine.  Change this:

If (Left(TextIn, 9) = "(%%[Page:") Then

To this, which tests to see if "%%[Page:" is in the string:

If (InStr(TextIn, "%%[Page:") > 0) Then
0
 
LVL 19

Expert Comment

by:Shauli
ID: 10682891
   Open FileName For Input As #1
    Do While (Not EOF(1))
        Line Input #1, TextIn
        If InStr(1, TextIn, "(%%[Page:") = 1 Then '<<<<<<<<<<,
            Count = Count + 1
        End If
    Loop
    Close #1
    MsgBox Count

S
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

746 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

16 Experts available now in Live!

Get 1:1 Help Now