-
How do I make my program count the amount of words in a text box?
-
here it is
Option Explicit ' make vars available to all routines.
Dim SingleCharacter As String
Dim i, j, k, CountWords, Count8 As Integer
Dim MyString() As String
Private Sub cmdGatherInfo_Click()
LineOfText = txtMain.Text 'initialize the variable.
For i = 1 To Len(LineOfText)
If Mid$(LineOfText, i, 1) <> " " Then
ReDim Preserve MyString(CountWords)
Do Until Mid$(LineOfText, i, 1) = " " Or i > Len(LineOfText)
MyString(CountWords) = MyString(CountWords) & Mid$(LineOfText, i, 1)
i = i + 1
Loop
CountWords = CountWords + 1
End If
Next