I am trying to write a proram that will search for character or letter and count how many times that character appears. The user will enter a phrase in a text box then press the search button, then an Inputbox will appear asking the user to enter a character. then a messagebox.show should appear giving the user the number of times the character appears. This is what I have so far. I am getting an error after i type the character i want to look for. Any help would be appreciated. Thanks.
Private Sub btnSearch_Click(sender As System.Object, e As System.EventArgs) Handles btnSearch.Click Dim keyword As Char Dim txtlength As Integer Dim intCounter As Integer = 0 txtlength = txtSearch.Text.Length() keyword = CChar(InputBox("What charater are you looking for?", "Search")) Do Until txtlength = intCounter If CBool(txtSearch.Text.Substring(CInt(intCounter), 1)) Then MessageBox.Show("The character appears " & intCounter & " times.") intCounter += 1 End If Loop end sub
Quoted Text Here