Program using the StringBuilder class that will accept string from user and will count the numbers of vowels in it.
Drag and Drop:
- A Button
- A Textbox
A Label
Public Class Stringbuilder Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mystring As String = TextBox1.Text Dim intnumber As Integer = 0 Dim chars As Char() = mystring.ToCharArray() Dim newString As System.Text.StringBuilder = New System.Text.StringBuilder() For Each c As Char In chars Dim strpattern As String strpattern = "[U,u,E,e,O,o,A,a,I,i]" Dim strstore As String strstore = c Like strpattern If strstore = True Then intnumber = intnumber + 1 End If Next c newString.Append("No. of vowels: " & intnumber) Label1.Text = newString.ToString() End Sub End Class