You could use a HashSet(Of String)
to store those exceptional words. Then split by white-space to get all words in a string, check whether you need to upper- or lowercase the first letter and use string.Join
to create a new string.
Here is a method that does it:
Private Shared ReadOnly CapCaseExceptions As New HashSet(Of String)(StringComparer.CurrentCultureIgnoreCase) From {
"the", "and", "an", "as", "to", "is", "on"
} ' etc.
Public Shared Function CapCase(input As String) As String
Dim words = From w In input.Split()
Let word = If(CapCaseExceptions.Contains(w),
Char.ToLower(w(0)) + w.Substring(1),
Char.ToUpper(w(0)) + w.Substring(1))
Select word
Return String.Join(" ", words)
End Function
Your sample input:
Dim input As String = "This Is The Best Webite On The Web"
Console.Write(CapCase(input)) ' This is the Best Webite on the Web
Edit: i'm not familiar with classic ASP, so i don't know if it helps.