[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Reading from file help

Posted on 2004-03-25
3
Medium Priority
?
189 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
[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
3 Comments
 
LVL 86

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 600 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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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

656 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