Public Function StrBld(ByVal strIn As String, ParamArray Items() As Variant) As String
Dim strStore As String, sSentCase() As String
Dim i As Integer, iPos As Integer, sChar As String * 2
On Error GoTo ERR_HANDLE
strStore = strIn
If Not IsMissing(Items) Then
For i = 0 To UBound(Items)
If Not IsMissing(Items(i)) Then
strIn = Replace$(strIn, "{" & i & "}", Items(i))
End If
Next i
End If
strIn = Replace$(strIn, "\tab", vbTab, , , vbBinaryCompare)
strIn = Replace$(strIn, "\\n", DBLINE, , , vbBinaryCompare)
strIn = Replace$(strIn, "\n", vbNewLine, , , vbBinaryCompare)
Do While InStr(1, strIn, "\u", vbBinaryCompare) > 0
iPos = InStr(1, strIn, "\u", vbBinaryCompare)
sChar = Replace$(Mid$(strIn, iPos, 4), "\u", "")
strIn = Replace$(strIn, "\u" & sChar, Chr$(Val("&H" & sChar)))
Loop
If Left$(strIn, 1) = "\" Then
Select Case Asc(Mid$(strIn, 2, 1))
Case 60: strIn = StrConv(Replace$(strIn, "\<", "", , , vbBinaryCompare), vbLowerCase)
Case 62: strIn = StrConv(Replace$(strIn, "\>", "", , , vbBinaryCompare), vbUpperCase)
Case 112: strIn = StrConv(Replace$(strIn, "\p", "", , , vbBinaryCompare), vbProperCase)
Case 115:
sSentCase = Split(Replace$(strIn, "\s", "", , , vbBinaryCompare), ".")
For i = 0 To UBound(sSentCase)
sSentCase(i) = Trim$(sSentCase(i))
For iPos = 1 To Len(sSentCase(i))
If Mid$(sSentCase(i), iPos, 1) Like "[A-Z]" Then Exit For
Next iPos
Mid$(sSentCase(i), iPos, Len(sSentCase(i))) = UCase$(Mid$(sSentCase(i), iPos, 1)) _
& LCase$(Mid$(sSentCase(i), iPos + 1, Len(sSentCase(i))))
Next i
strIn = Trim$(Join$(sSentCase, ". "))
End Select
End If
StrBld = strIn
EXIT_PROC:
Erase sSentCase
Exit Function
ERR_HANDLE:
Select Case Err
Case 3021, 94, 5
Case Else
VBA.MsgBox Error$ & ", With StrBld()" & DBLINE _
& "Please Check String = '" & strStore & "'", 4160, "Error#" & Err
End Select
Err.Clear
Resume Next
End Function
|