Article ID: 154600
Article Last Modified on 1/19/2007
Function ParseArticle(strOldTitle As String, Optional varKeepArticle _
As Variant) As String
' strOldTitle is the field or value you want to parse.
' varKeepArticle is an optional variant value that, when left blank,
' will completely remove the article (for example, "The Beatles" becomes
' "Beatles.")
On Error GoTo Err_Result
Dim intLength As Integer, strArticle As String
If IsMissing(varKeepArticle) Then
varKeepArticle = False
End If
intLength = Len(strOldTitle)
strArticle = ""
' Check Value for preceding article (a, an, or the).
If Left(strOldTitle, 2) = "a " Then
strArticle = ", " & Left(strOldTitle, 1)
strOldTitle = Right(strOldTitle, intLength - 2)
ElseIf Left(strOldTitle, 3) = "an " Then
strArticle = ", " & Left(strOldTitle, 2)
strOldTitle = Right(strOldTitle, intLength - 3)
ElseIf Left(strOldTitle, 4) = "the " Then
strArticle = ", " & Left(strOldTitle, 3)
strOldTitle = Right(strOldTitle, intLength - 4)
End If
' If varKeepArticle is TRUE, then add the article string to the end.
If varKeepArticle Then
ParseArticle = strOldTitle & strArticle
Else
ParseArticle = strOldTitle
End If
Exit Function
Err_Result:
ParseArticle = "#Error"
End Function
Additional query words: remove ignore parse
Keywords: kbhowto KB154600