This blog defines the the number of vowels in a string using VB.NET.

In this blog we enter a string and the below program count the number of vowels from the string.

Vowels = a,e,i,o,u

VB.NET code

Module Module1

Sub Main()

Dim I As Integer

Dim nVowels As Integer

Dim Vowels As String

Dim InputString As String

Vowels = "aeiou"

Console.WriteLine("Enter the string :")

InputString = Console.ReadLine()

For I = 1 To Len(InputString)

If InStr(Vowels, Mid(InputString, I, 1)) Then

nVowels = nVowels + 1

End If

Next

Console.WriteLine("The total vowels are :" & nVowels)

End Sub

End Module

OUTPUT

v2.gif