'********************************************************************
'*
'* Function strInsert
'*
'* Author: NetworkAdminKB.com
'* Created: 2005-11-03
'* Modified: 2008-12-08
'*
'* Purpose: Returns the original string with the substring inserted
'* at the desired location.
'*
'* Input: strSource = The original string string
'* strIn = A string/Character to be inserted into
'* the srouce string.
'* anyLoc = A the numbered location, character or substring
'* to insert strIn After.
'* blnCase = A boolean indicating case sensitive searches
'* True = Case Sensitive Search
'* False = Case Insensitive Search
'*
'* Output: Returns the original string with the substring inserted
'* at the desired location.
'* If there is no match on anyLoc OR anyLoc is not between 1
'* and Len(strSource) then Empty is Returned.
'*
'* Examples: strInsert("stay there", "over ", "y ", False) = "stay over there"
'* strInsert("stay there", "over ", 5, False) = "stay over there"
'*
'* Calls:
'* ReturnCaseComparisonValue
'*
'* Changes:
'* 2008-12-08: Use ReturnCaseComparisonValue to return intSearch value.
'********************************************************************
Function strInsert(ByVal strSource, ByVal strIn, ByVal anyLoc, ByVal blnCase)
'Version 1.1 2008-12-08
Dim intSearch, intStartPos, intEndPos, strStart, strEnd
intSearch = ReturnCaseComparisonValue(blnCase)
If IsNumeric(anyLoc) Then
intStartPos = anyLoc
Else
intStartPos = InStr(1, strSource, anyLoc, intSearch)
If intStartPos > 0 Then
intStartPos = intStartPos + Len(anyLoc) - 1
End If 'intStartPos
End If 'IsNumeric(anyLoc)
If (intStartPos > 0) And (intStartPos =< Len(strSource)) Then
intEndPos = intStartPos + 1
strStart = Left(strSource, intStartPos)
strEnd = Mid(strSource, intEndPos, Len(strSource))
strInsert = strStart & strIn & strEnd
Else
strInsert = Empty
End If 'intStartPos
End Function 'strInsert
Article ID: 424, Created On: 9/25/2011, Modified: 9/25/2011