''
'' FF_STRDELETE
'' Delete a specified number of characters from a string expression.
''
'' Returns a string based on MainString but with nCount characters deleted
'' starting at position nStart. The first character in the string is position 1, etc.
''
Function FF_StrDelete( ByRef sMainString As String, _
ByRef nStart As Integer, _
ByRef nCount As Integer _
) As String
Dim nLenMain As Integer = Len(sMainString)
If nStart > nLenMain Then Return sMainString
If nStart < 0 Then Return sMainString
If nCount <= 0 Then Return sMainString
If nStart = 0 Then nStart = nLenMain - nCount
' Try to avoid string concatentation as much as possible for speed consideration.
' Therefore, create the full buffer and insert by moving memory into the string.
Dim s As String = Space(nLenMain - nCount)
MemMove( Strptr(s), Strptr(sMainString), nStart - 1 )
MemMove( Strptr(s)+nStart-1, Strptr(sMainString)+nStart+nCount-1, nCount )
Function = s
End Function