i want to find how many time a specified word from a textbox , is in a file text.
this is my code but its not enough because i want to split all the file text to find how time is that word in the file.please help me!
this is my code but its not enough because i want to split all the file text to find how time is that word in the file.please help me!
Code:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim streamreader As System.IO.StreamReader
Dim nr_fjales As Integer
nr_fjales = 0
Dim i As Integer
streamreader = File.OpenText("C:\Users\user\Desktop\file.txt")
Dim cont As String
cont = streamreader.ReadToEnd.Split(" ").ToString
For i = 0 To streamreader.EndOfStream
If TextBox1.Text = cont Then
nr_fjales = nr_fjales + 1
End If
Next
Label2.Text = nr_fjales
streamreader.Close()
End Sub
End Class
Comment