Solved

help with vbs

Posted on 2011-09-02
2
324 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 53

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

15 Experts available now in Live!

Get 1:1 Help Now