|
-
Jul 20th, 2005, 08:19 AM
#1
Thread Starter
Lively Member
Character Count & Word Count
How Do I do this with a richtextbox and make it display either character or word count in another textbox
Thanks for your help,
lavarock09
-
Jul 20th, 2005, 08:21 AM
#2
-
Jul 20th, 2005, 08:23 AM
#3
Re: Character Count & Word Count
For word count you can do something like this (if you assume that every word is separated by a space and not other characters) :
VB Code:
Private Sub Text1_Change()
Text2.Text = UBound(Split(Text1.Text, " "))
End Sub
Has someone helped you? Then you can Rate their helpful post. 
-
Jul 20th, 2005, 08:53 AM
#4
Re: Character Count & Word Count
To take manavo11's suggestion just a little step further, try this:
VB Code:
Private Function GetWordCount(ByVal pstrText As String) As Long
pstrText = Trim(Replace(pstrText, "-" & vbNewLine, ""))
pstrText = Trim(Replace(pstrText, vbNewLine, " "))
Do While pstrText Like "* *"
pstrText = Replace(pstrText, " ", " ")
Loop
GetWordCount = 1 + UBound(Split(pstrText, " "))
End Function
Private Sub Command1_Click()
MsgBox GetWordCount(RichTextBox1.Text)
End Sub
-
Jul 20th, 2005, 09:22 AM
#5
Thread Starter
Lively Member
Re: Character Count & Word Count
Excellent, Exactly what I wanted,
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|