• We just launched and are currently in beta. Join us as we build and grow the community.

Word Count Program in VB,NET

MKS_269

Console Collector
M Rep
0
0
0
Rep
0
M Vouches
0
0
0
Vouches
0
Posts
153
Likes
43
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
For this article, we will create a program that will count the number of words in a TextBox. But we will just use the RichTextBox instead of TextBox :)

Now, let's start this tutorial!

1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.

2. Next, add one RichTextBox named RichTextBox1 and a Button named Button1 labeled as "Get Number of Words". You must design your layout like this:

wordcountdesign.png


3. Now put add this code for your code module. This code is for Button1_Click. This will trigger to count the number of words in your RichTextBox.

  1. Private

    Sub

    Button1_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button1.

    Click
  2. Dim

    strInput As

    String
  3. strInput =

    RichTextBox1.

    Text
  4. Dim

    strSplit(

    )

    As

    String
  5. strSplit =

    strInput.

    Split

    (

    CChar

    (

    " "

    )

    )
  6. MsgBox

    (

    "Number of words: "

    &

    strSplit.

    Length

    )
  7. End

    Sub

Explanation:

We have initialized variable strInput as String to hold the value inputted in the RichTextBox. We also declare variable strSplit as string to split the words inputted in the RichTextBox. We use the CChar function to find the spacing of the text. Then we create a MessageBox to display the number of words using the Length function.

Output:

wordcountoutputpng_1.png


Download the source code and try it!

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon R. Bermoy

IT Instructor/System Developer/Android Developer

Mobile: 09079373999

Telephone: 826-9296

E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,526

323,535

Top