I have until the end of today to find a way to stop my word counter counting (word)..(word). as 2 sentences when it isnt! i want it to count one full stop as a sentence but not two or three!! HELP!
VB Code:
Private Sub cmdsentences_Click() Dim Sentence As String, Char As String 'setting the data types Dim Count As Integer, I As Integer 'setting the data types Count = 0 'initialise the count to 0 Sentence = Trim(txtInput.Text) 'set the end of the sentence. If Len(Sentence) > 0 Then 'if there is no text, count stays at zero For I = 1 To Len(Sentence) 'when it does have characters then execute instructions Char = Mid(Sentence, I, 1) 'characters in sentence If Char = "." Or Char = "?" Or Char = "!" Then 'characters which show end of sentence(loop begins) Count = Count + 1 'add one to count End If Next I Count = Count 'count remains the same End If lblCountsentences.Caption = Count 'where to display the result End Sub




Reply With Quote