Dim intCount as Integer, strLine as String
strLine = "This is a test."
intCount = 0
For intCount = 1 to Len(strLine)
If Mid(strLine, intCount, 1) = " " Then
intCount = intCount + 1
End If
Next intCount
If intCount = 1 Then
MsgBox "There is " & intCount " space in the test string.", _
vbInformation, "Space Count"
Else
MsgBox "There are " & intCount " spaces in the test string.", _
vbInformation, "Space Count"
End If
|