Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Using the Instr Function

Posted on 2003-02-26
3
Medium Priority
?
206 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
  • 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

Industry Leaders: 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

In this post we will learn different types of Android Layout and some basics of an Android App.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Introduction to Processes
Starting up a Project

571 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