Solved

help with vbs

Posted on 2011-09-02
2
320 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
Comment Utility
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 51

Expert Comment

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

~bp
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

13 Experts available now in Live!

Get 1:1 Help Now