' Visual Basic .NET Document Option Strict On ' Imports System.Collections.Generic Imports System.Runtime.CompilerServices Public Module StringLib Private exclusions As List(Of String) Sub New() Dim words() As String = {"a", "an", "and", "of", "the"} exclusions = New List(Of String) exclusions.AddRange(words) End Sub _ Public Function ToTitleCase(title As String) As String Dim words() As String = title.Split() Dim result As String = String.Empty For ctr As Integer = 0 To words.Length - 1 Dim word As String = words(ctr) If ctr = 0 OrElse Not exclusions.Contains(word.ToLower()) Then result += word.Substring(0, 1).ToUpper() + _ word.Substring(1).ToLower() Else result += word.ToLower() End If If ctr <= words.Length - 1 Then result += " " End If Next Return result End Function End Module ' ' Public Module Test ' Public Sub Main ' Console.WriteLine("war and peace".ToTitleCase()) ' End Sub ' End Module