Wednesday, May 12, 2021

Add, Find, and Count Words in Microsoft Visual Basic NET

 A simple program that I wrote in Microsoft Visual Basic NET to count, add, and find words in the text box I hope you will find my work useful.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com






Program Listing

' Created By Mr. Jake Rodriguez Pomperada, MAED-IT, MIT

' www.jakerpomperada.com and www.jakerpomperada.blogspot.com

' jakerpomperada@gmail.com

' Bacolod City, Negros Occidental Philippines


Public Class Form1


    Function wordCount(ByVal str As String)

        Dim NumberOfWord As Integer

        NumberOfWord = UBound(Split(Trim(Replace(str, Space(2), Space(1))))) + 1

        Return NumberOfWord

    End Function


    Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged

        If RichTextBox1.Text.ToLower = "" Then

            TextBox1.Text = "0"

        Else

            TextBox1.Text = wordCount(RichTextBox1.Text.ToLower)

        End If


    End Sub


    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click


        Dim str_input As String


        str_input = (TextBox2.Text.ToLower)


        RichTextBox1.AppendText(str_input + " ")

    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim text1 As String


        text1 = (RichTextBox1.Text)

        Dim mysplit As Array

        mysplit = Split(text1, TextBox3.Text)

        Dim count As Integer


        count = mysplit.Length - 1


        Label4.Text = "No. of Matches : " & count

        Label5.Text = "Find Word : " & TextBox3.Text.ToUpper

    End Sub


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

        TextBox2.Text = ""

        TextBox3.Text = ""

        RichTextBox1.Text = ""

        Label4.Text = ""

        Label5.Text = ""

    End Sub


    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

        MsgBox("Created By Mr. Jake Rodriguez Pomperada, MAED-IT, MIT " & vbCrLf _

               & "www.jakerpomperada.com and www.jakerpomperada.com" & vbCrLf _

               & "jakerpomperada@gmail.com", MsgBoxStyle.Information, "About this Program")

    End Sub

  

End Class


DOWNLOAD THE COMPLETE SOURCE CODE HERE


No comments:

Post a Comment