Solved

help with vbs

Posted on 2011-09-02
2
322 Views
Last Modified: 2012-05-12
I got a text file that looks like

aaa|zzz|sss
vvv|bbb|ccc

What I want to do is to open the txt file and search for bbb.
If the string is found then output  write found if not not found.
Does anybody knows how to do this?
0
Comment
Question by:kt2003
2 Comments
 
LVL 10

Accepted Solution

by:
aboo_s earned 500 total points
ID: 36476898
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\sample.txt", ForReading)

Const ForReading = 1

Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close

found=0


For Each strLine in arrFileLines

Result = InStrRev(strLine, "|bbb|")
If Result > 0 Then
      document.write("Found!")
End If
Next


0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 36477622
Can the "bbb" ever be the first thing on a line, or the last thing on a line?

~bp
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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

20 Experts available now in Live!

Get 1:1 Help Now