How do I count characters using substing and a do while loop?
Im trying to make a pogram that will allow the user to type in a phrase and when they click on the search button an inputbox will appear asking for what character to search for. The user types the character in and then a messagebox should tell him how many times the character appears in the phrase. I'm having trouble counting the characters. I have to use substring and do while.
Dim keyword As Char Dim intCounter As Integer = 0 Dim strUserInput As String = "" Dim txtlength As Integer strUserInput = CStr(txtSearch.Text) txtlength = strUserInput.Length() txtlength = AscW(keyword) keyword = CChar(InputBox("What charater are you looking for?", "Search")) Do While txtlength > intCounter txtSearch.Text.Substring(0, 1) MessageBox.Show("the character " & keyword & " appears " & intCounter & " times") intCounter += 1 Loop End Sub