Count Char and words

jashgtp

Registered User.
Local time
Yesterday, 18:11
Joined
Mar 13, 2009
Messages
16
I searched but did not really find a clear answer.

I have variable called post1, which is a memo data type.

Post will be filled with a persons response to a question.

I would like access to automatically calculate the number of words and put that number in a variable called numword

also calculate the number of characters not including spaces and put that number in a variable called numchar


What would be the best way to do this?

Thanks.


Also, if i have another variable called post2 and post3. could i have access calculate a total number of words and chars from the three varibles post1, post2, and post3?? and place that information in a vaible called totword and totchar?
 
jashgtp,

Code:
Dim varArray As Variant
'
varArray = Split(post1, " ")
numword = UBound(varArray) + 1
'
numchar = Len(Replace(post1, " ", ""))

Wayne
 
do i just put that as code on the form?

seems really simple to do all the things i need it to do
 
got some assistance and this seems to work for me pretty good

Private Sub Post1_AfterUpdate()
If Len(Me.Post1) > 0 Then
Me.NumChar = Len(Post1) - (Len([Post1]) - Len(Replace([Post1], " ", "")))
Me.NumWord = (Len([Post1]) - Len(Replace([Post1], " ", ""))) + 1
Else
Me.NumChar = 0
Me.NumWord = 0
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom