jebuntin
08-14-2001, 12:36 PM
Is there any way to calculate how many words there are in a memo field? And also maybe limit the amount of words that can be entered?
|
View Full Version : word count jebuntin 08-14-2001, 12:36 PM Is there any way to calculate how many words there are in a memo field? And also maybe limit the amount of words that can be entered? sned 08-15-2001, 02:24 AM This code will count the number of words in a memo field when the control has lost the focus. It could also be used on OnUpdate. Private Sub mmoSecond_LostFocus() Dim First$ 'Variable to hold memo string Dim arr As Variant 'Variable to hold string when split (array) Dim n% 'Variable to hold number of words (size of Array) First$ = mmoSecond.Text 'Get text from Memo field First$ = Replace(First$, " ", " ", 1) 'Remove double spaces arr = Split(First$, " ") 'Split up into individual words n% = UBound(arr) + 1 'Find size of Array txtFirst.SetFocus 'Set focus to text field to display number of words txtFirst.Text = n% 'Set the value of the text field End Sub Sned |