It should work exactly as it isVB 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 Sentence = Replace$(Sentence, "?", ".") Sentence = Replace$(Sentence, "!", ".") Do Until Instr(Sentence, "..") = 0 Sentence = Replace$(Sentence, "..", ".") Loop 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 [b]Don't need to do this=>[/b] Count = Count 'count remains the same End If lblCountsentences.Caption = Count 'where to display the result End Sub




Reply With Quote