Showing posts with label word count in visual basic net. Show all posts
Showing posts with label word count in visual basic net. Show all posts

Monday, May 1, 2017

Word Count in Visual Basic NET

In this article I would like to share with you a sample program that will ask the user to give a sentence or string and then our program will count the number of words in the given word or sentence using Microsoft Visual Basic NET.  The source code is very short and very easy to understand.  Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Sample Program Listing


Program Listing

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim strInput As String
        strInput = TextBox1.Text
        Dim strSplit() As String
        strSplit = strInput.Split(CChar(" "))
        Label2.Text = "Number of words: " & strSplit.Length
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label2.Text = ""
        TextBox1.Focus()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub
End Class