And also how many words are in the file. Please help!Need : VB Code to count how many times words are used in a text file?
Imports System.IO
'Find How many times a word is used in a text file
Private Function FindWordOccourance(ByVal fileName As String, ByVal stringToFined As String) as Integer
Dim str() As String = File.ReadAllLines(fileName)
Dim I as Integer = 0
Using sw As New IO.StreamWriter(fileName)
For Each Line As String In str
If (Line.Contains(strToFined)) Then
I = I + 1
End If
Next
End Using
Return I
End Sub
'Find how many words in a text file
Private Function CountWords(ByVal fileName As String) as Integer
Dim str() As String = File.ReadAllLines(fileName)
Dim Words() as string = str.Split('; ';)
Return Words.Length
End Sub
No comments:
Post a Comment