yep so now instead of counting the words in the selected text, i count the sentences and search through each sentence for a comma and display how many times a comma occured in each sentence (is 1 comma in first sentence, 0 in second etc) , i thought i'd use the same findChar function as before:
And then call it from the main program as this:VB Code:
Private Function findChar(Text As String, myChar As String) As Integer 'Returns a Integer value Dim counter As Integer Dim iPos As Integer counter = 0 iPos = 0 iPos = InStr(1, Text, myChar) Do While iPos > 0 iPos = InStr(iPos, Text, myChar) If iPos > 0 Then iPos = iPos + 1 counter = counter + 1 End If Loop findChar = counter End Function
VB Code:
'Prints out sentences highlighted Dim sentenceCount As Integer Dim newCount As Integer 'Gets number of all sentences selected sentenceCount = Selection.Sentences.count newCount = sentenceCount - 1 'If sentenceCount > 0 Then ' MsgBox "Sentences selected = " & newCount ' Else ' MsgBox "Sentences selected = 0" ' End If Do While sentenceCount > 0 'if sentence highlighted commaCount = findChar(myText, ",") 'find comma sentenceCount = sentenceCount - 1 'suppose to iterate Loop MsgBox "commas found in sentence" & sentenceCount & "equals " & commaCount 'but only comes out with total number of comma's in all sentences
??




Reply With Quote