Word Counter
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
5 posts
Page 1 of 1
Design:
USE THIS CODE:(THANKS MANDAI FOR THE NOTICE!
Screenshots:
Please +Rep me!
Code:
Code: Select all
DONT USE THE ONE AT THE BOTTOM!!
Dim spaceArray As String() = RichTextBox1.Text.Replace(vbLf, " ").Split(" "c)
Dim wordcount As Integer = 0
For i As Integer = 0 To spaceArray.Length - 1
If spaceArray(i).Length > 0 Then wordcount += 1
Next
Label1.Text = "Words: " & wordcount
Code: Select all
Public Class Form1
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
Dim wordcount As Integer
Dim num As String() = RichTextBox1.Text.Split(" ")
wordcount = num.Length
Label1.Text = "Words: " & wordcount
If RichTextBox1.Text = "" Then
Label1.Text = "Words: 0"
Else
Label1.Text = "Words: " & wordcount
End If
End Sub
End Class
Screenshots:
Please +Rep me!
You do not have the required permissions to view the files attached to this post.
Last edited by code it on Sun Jan 09, 2011 9:31 pm, edited 2 times in total.
This counts space characters as words, plus it doesn't continue on newlines.
I made some code that will only count the words: viewtopic.php?f=32&t=3776&p=26595#p26595
I made some code that will only count the words: viewtopic.php?f=32&t=3776&p=26595#p26595
Last edited by mandai on Sun Jan 09, 2011 6:28 pm, edited 1 time in total.
This checks for spaces,
if you have a string "hello world" wich contain 2 spaces, the word count will be 3 i guess
if you have a string "hello world" wich contain 2 spaces, the word count will be 3 i guess
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023