Solved

Reading from file help

Posted on 2004-03-25
3
183 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

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now