VB.Net Count Words In Text File

How to Count the Number of Words in a Text File Using Visual Basic .Net

Count Words In Text File Using VB.Net


In this VB.NET Tutorial we will see How To Get The Number Of Words Inside A Text File And Display The Returned Number In A Label Using Visual Basic.Net  Programming Language And Visual  Studio Editor.



Project Source Code:


Imports System.IO

Public Class COUNT_WORDS_IN_TEXT_FILE

    Private Sub ButtonCount_Click(sender As Object, e As EventArgs) Handles ButtonCount.Click

        Dim filePath As String = TextBox1.Text
        Dim lines() As String = File.ReadAllLines(filePath)

        Dim separator() As Char = {" "}
        Dim count As Integer = 0

        For i As Integer = 0 To lines.Length - 1 Step +1

            count += lines(i).Split(separator, StringSplitOptions.RemoveEmptyEntries).Length

        Next

        Label1.Text = count.ToString()

    End Sub
End Class


OutPut:

get the number of words in a txt file using vb.net




Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer