TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hari B
NA
139
67.7k
Print Specific line in vb Script
Aug 23 2014 4:52 AM
i have one text file like below
This is Hareesh
This is Sampath
This is Hareesh
This is Sampath
This is Hareesh
This is Hareesh
This is Sampath
This is Hareesh
This is Sampath
This is Hareesh
This is Sampath
This is Hareesh
i want print This is Hareesh only how many occurences that all will be print.
here is my code
Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "Hareesh"
objRegEx.Ignorecase = true
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\Hareesh\Desktop\From_Sampath\Test.txt", ForReading)
strSearchString = objFile.ReadAll
objFile.Close
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
strMessage = "The following user accounts were found:" & vbCrlf
For Each strMatch in colMatches
msgbox strMessage
strMessage = strMessage & strMatch.Value & " (character position " & _
strMatch.FirstIndex & ")" & vbCrLf
Next
End If
Wscript.Echo strMessage
Reply
Answers (
0
)
VBA Script for Excel to check the system certificates?
Set Focus on TextBox