Simple ProperCases Names McDonald and O'Conel
Simple ProperCases Names McDonald and O'Conel
Rate Simple ProperCases Names McDonald and O'Conel
(1(1 Vote))
Dim strValue As String
Dim iWords As Integer
If CStr(Value) <> "" Then
Value = Split(Value, " ")
If IsArray(Value) = True Then
Do Until UBound(Value, 1) + 1 = iWords
strValue = strValue & NameProperCaseConvert(Value(iWords)) & " "
iWords = iWords + 1
Loop
strValue = Trim(strValue)
Else
strValue = NameProperCaseConvert(CStr(Value))
End If
NameProperCase = strValue
Else
NameProperCase = ""
End If
End Function
Function NameProperCaseConvert(ByVal Value As String) As String
Dim intRetValue As Integer
Dim strValue As String
strValue = UCase(Left(Value, 1)) & LCase(Mid(Value, 2))
'Checks if name is O'Brain or O'Shear
intRetValue = InStr(1, Value, "'")
If intRetValue >= 1 Then
strValue = UCase(Left(Value, 1)) & Mid(Value, intRetValue, 1) & UCase(Mid(Value, intRetValue + 1, 1)) & LCase(Mid(Value, intRetValue + 2))
End If
intRetValue = InStr(1, Value, "Mc", 1) ' vbTextCompare
If intRetValue >= 1 Then
strValue = UCase(Left(Value, 1)) & LCase(Mid(Value, 2, 1)) & UCase(Mid(Value, intRetValue + 2, 1)) & LCase(Mid(Value, intRetValue + 3))
End If
'intRetValue = InStr(1, Value, "Mac", 1) ' vbTextCompare
'If intRetValue >= 1 Then
' strValue = UCase(Left(Value, 1)) & LCase(Mid(Value, 2, 2)) & UCase(Mid(Value, intRetValue + 3, 1)) & LCase(Mid(Value, intRetValue + 4))
'End If
NameProperCaseConvert = strValue
End Function
Simple ProperCases Names McDonald and O'Conel Comments
No comments yet — be the first to post one!
Post a Comment