how can i Read a txt file and output all words wtih a number of how many words there are.
example
hey my name is is hey hey hey i like like this
hey : 4
my : 1
name: 1
is: 2
i : 1
like 2
this : 1
i have this:
'Option Explicit
Dim objTextFile,ForReading,objFSO,objOpen
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOpen = objFSO.OpenTextFile("C:\Users\mib\.oracle_jre_usage\Desktop\olsenbanden.txt")
strContents = CStr(objOpen.ReadAll)
WScript.Echo(strContents)
okay i have tried this now but doesn't work:
Dim x
x=10
set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Users\mib\.oracle_jre_usage\Desktop\olsenbanden.txt",1)
Dim strLine
Dim total_words
total_words = 0
do while not objFileToRead.AtEndOfStream
strLine = objFileToRead.ReadLine()
a=Split(strLine,":")
for each x in a
if IsNumeric(x) then
total_words = total_words + 1
end if
next
loop
objFileToRead.Close
Set objFileToRead = Nothing
WScript.Echo(IsNumeric(x) & "<br />")