?
Solved

Using the Instr Function

Posted on 2003-02-26
3
Medium Priority
?
202 Views
Last Modified: 2010-04-17
I am looping through an array called strLines to find strDelete.  If strDelete is not there, i am writing strLines(i) to a text file.

However, if strDelete is contained within strLines(i) - i want to replace strDelete with "" & then write the line.

The code i have is as follows:

For i = LBound(strLines) To UBound(strLines)
    If strLines(i) <> strDelete Then
        Write #1, strLines(i)
    End If
   
    pos = InStr(0, strLines(i), strDelete, vbTextCompare)
    If pos = 0 Then  //not in strLines(i)
         Write #1, strLines(i)
    Else
         strLines(i) = Replace(strLines(i), strDelete, "")
         Write #1, strLines(i)
    End If
Next
Close #1


The error I'm receiving is runtime error 5: Invalid procedure call or argument on line:  pos = ......


Any suggestions please?
0
Comment
Question by:Cbel
[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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
fluglash earned 150 total points
ID: 8024276
InStr(strLines, strDelete)
0
 
LVL 7

Expert Comment

by:fluglash
ID: 8024283
as default its compare option is vbTextCompare
0
 

Author Comment

by:Cbel
ID: 8024367
Cheers, that worked.  
0

Featured Post

Independent Software Vendors: 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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Introduction to Processes

764 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