0% found this document useful (0 votes)
26 views

Exercise 12

This Visual Basic code counts the number of vowels in text entered into a text box. When a button is clicked, it loops through each character in the input, checks if it is a vowel, and increments a counter if it is. It then displays the input text and the vowel count on a label.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Exercise 12

This Visual Basic code counts the number of vowels in text entered into a text box. When a button is clicked, it loops through each character in the input, checks if it is a vowel, and increments a counter if it is. It then displays the input text and the vowel count on a label.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim allvowels As String
Dim input As String = TextBox1.Text
allvowels = "aeiouy"
Dim num As Integer = 0
For Each c As Char In input
If allvowels.Contains(c) Then
num = num + 1
End If
Next
Label2.Text = Label2.Text + " " + input + " is: " + num.ToString
End Sub
End Class

You might also like