... finally
The following commands are included:Code:Public Function Strip(ByVal paramPhrase As String, ByVal paramRemove As String, paramSearchType As Integer) As String
'Strip characters from the string...
'version 1.0
Dim strLast As String
Dim strTemp As String
Dim strChar As String
Dim strWord As String
Dim lngWord As Long
Dim i As Long
Dim j As Long
Dim n As Long
On Error GoTo Strip_Error
'Depad the phrase and word list...
If paramSearchType = sysStripWord Then
paramPhrase = DePad(paramPhrase, " ")
paramRemove = " " + DePad(paramRemove, " ") + " "
End If
'Main routine...
Select Case paramSearchType
'Strip out each character...................................................................................
Case sysStripChar
For n = 1 To Len(paramPhrase)
strChar = Mid$(paramPhrase, n, 1)
If InStr(paramRemove, strChar) = 0 Then strTemp = strTemp + strChar
Next n
'Strip out each word........................................................................................
Case sysStripWord
'Assign the strings...
strLast = Trim(paramRemove) + " "
strTemp = " " + Trim(paramPhrase) + " "
'Look for the next space in Last and get the word...
j = 1
i = InStr(2, strLast, " ")
strWord = " " + LEFT$(strLast, i - 1) + " "
'Repeat while there's a space left...
While i > 0
'Determine if the word is in the string...
n = InStr(strTemp, strWord)
While n > 0
'...then take it out...
lngWord = Len(strWord)
If n + lngWord < Len(strTemp) Then
strTemp = LEFT(strTemp, n - 1) + Mid(strTemp, n + lngWord) 'Middle of the string...
Else
strTemp = LEFT(strTemp, n - 1) 'End of the string...
End If
'...and do it all again...
n = InStr(strTemp, strWord)
Wend
'Get the next word...
j = i + 1
i = InStr(j, strLast, " ")
If i > 0 Then strWord = " " + Trim(Mid$(strLast, j, i - j)) + " "
Wend
'Strip out the phrase.......................................................................................
Case sysStripPhrase
strTemp = paramPhrase
i = InStr(strTemp, paramRemove)
lngWord = Len(paramRemove)
While i > 0
If i + lngWord < Len(strTemp) Then
strTemp = LEFT(strTemp, i - 1) + Mid(strTemp, i + lngWord)
Else
strTemp = LEFT(strTemp, i - 1)
End If
i = InStr(strTemp, paramRemove)
Wend
End Select
Strip = DePad(Trim(strTemp), " ")
Strip_Error:
If Err.number <> 0 Then
MsgBox Err.DESCRIPTION, vbCritical, "Strip"
End If
End Function
<out_date> = LastSunday(<any_date>)
Returns the Sunday prior to the date indicated. Please note that this function forces Sunday as the first day of the week.
<out_date> = IsLeapYear([<any_date>])
Uses a fairly basic boolean calculation to assess whether the year specified is a leap year. Default is the current year.
<crlf_str> = crlf([<numberof_int>])
Creates a list of one or more vbCrLf's. (Very useful in the Query builder of M$ Access).
<item_str> = GetListItem(<itemlist_str>, <item_lng>[, <delim_str>)
Gets the n'th item from a list (string) delimitted by comma (default) or the character specified by the programmer.
<items_lng> = CoutListItems(<itemlist_str>[, <delim_str>)
Counts the number of items in a text list separated by comma (default) or the character specified by the programmer.
<text_str> = DePad(<phrase_str>[, <char_str>)
Depads (removes) multiple occurrences of the same character (default = space).
<text_str> = Strip(<phrase_str>, <remove_str>, <mode_int>)
Strips the specified characters, word or phrase from the <phrase_str> based on the mode (1 = Character, 2 = Word, 3 = Phrase).
Hope these prove useful to some of you.
Regards,
