Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Count Vowels

Imports System.IO public class Test    public Shared Sub Main         Console.WriteLine("VOWELS COUNTED: " & CountTheVowels("asdffdsaasdf"))    End Sub     Private Shared Function CountTheVowels(ByVal strSomeString As String) As Integer         Dim intCount As Integer = 1         Dim intTotal As Integer = 0         Dim intPosition As Integer         'Loop through the string and count the vowels.         Do While intCount <= strSomeString.Length             intPosition = InStr("aeio", strSomeString.Substring(intCount, 1).ToLower)             If intPosition > 0 Then                 intTotal += 1             End If         Loop         Return intTotal     End Function     End class