|
-
Apr 15th, 2000, 02:54 PM
#1
Does anyone know how to create word count in VB?
I just want to count words in writing program, such as, MS Word or Wordpad.
Please let me know if you know.
Thank you
Aki
-
Apr 15th, 2000, 04:18 PM
#2
transcendental analytic
Something like this?
Code:
Function wordcount(txt as string) ' returns the amount of word in txt
Dim pos As Long
If Len(txt) = 0 Then Exit Function
pos = InStr(txt, " ")
Do Until pos = 0
wordcount = wordcount + 1
pos = InStr(pos + 1, txt, " ")
Loop
wordcount = wordcount + 1
End Function
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 16th, 2000, 01:06 AM
#3
Thanks
Thanks Kedaman.
I am pretty sure that will help me.
but one more question.
Can I specify a vocabulary?
I mean, for example, a user can put any vocabulary in the text box, and count. like, How many vacabulary "car" are there in a text?
I will try my best, but if anyone konws the answer, PLEASE tell me.
Thanks
aki
-
Apr 16th, 2000, 06:39 AM
#4
Frenzied Member
You could use Kedaman's code almost the same as it is, but instead of searching for the string " " you're looking for your word. So it would look something like this:
Code:
Function wordcount(txt as string, word as string) ' returns the amount of word in txt
Dim pos As Long
If Len(txt) = 0 Then Exit Function
pos = InStr(txt, word)
Do Until pos = 0
wordcount = wordcount + 1
pos = InStr(pos + len(word), txt, word)
Loop
wordcount = wordcount + 1
End Function
I'm fairly sure that will do it.
Hope it helps
Harry.
"From one thing, know ten thousand things."
-
Apr 16th, 2000, 10:09 AM
#5
Thanks, HarryW. That really helped me.
Thank both of you very much
aki
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
|