-
hey, i was asking for the word count function...
you used this function
' Split the text into words.
vArray = Split(Text1.Text, " ")
what is the "split" function it is readable by VB
if any one else knows what this is please respond, this is the full code used to count the words in a text field.
Dim vArray As Variant
Dim intIndex As Integer
Dim intCount As Integer
Dim intWords As Integer
' Split the text into words.
vArray = Split(txtMain.Text, " ")
' Find those longer than 8
For intIndex = 0 To UBound(vArray)
If Len(vArray(intIndex)) > 8 Then
intCount = intCount + 1
End If
If Trim(vArray(intIndex)) <> "" Then
intWords = intWords + 1
End If
Next
MsgBox "txtmain contains " & intWords & " words " _
& "of which " & intCount & " are longer than 8 characters"
-
Split is a new VB6 function.
-
Here's a VB5 version
Code:
Dim strArray() As String
Dim intIndex As Integer
Dim intCount As Integer
Dim intWords As Integer
' Split the text into words.
For intIndex = 1 To Len(Text1)
If Mid$(Text1, intIndex, 1) <> " " Then
ReDim Preserve strArray(intWords)
Do Until Mid$(Text1, intIndex, 1) = " " Or intIndex > Len(Text1)
strArray(intWords) = strArray(intWords) & Mid$(Text1, intIndex, 1)
intIndex = intIndex + 1
Loop
intWords = intWords + 1
End If
Next
' Find those longer than 8
For intIndex = 0 To UBound(strArray)
If Len(strArray(intIndex)) > 8 Then
intCount = intCount + 1
End If
Next
MsgBox "txtmain contains " & intWords & " words " _
& "of which " & intCount & " are longer than 8 characters"
End Sub