Article ID: 175390
Article Last Modified on 11/6/2000
Function ParseArticle(strOldTitle As String, varKeepArticle _
As Variant) As String
' strOldTitle is the field or value you want to parse.
' varKeepArticle is a variant value that, when False, completely
' removes the article (for example, "The Beatles" becomes "Beatles").
' If varKeepArticle is True, the function places the article at the
' end of the string returned by the function (for example,
' "The Beatles" becomes "Beatles, The").
On Error GoTo Err_Result
Dim intLength As Integer, strArticle As String
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 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 kbusage KB175390