April 1, 2000

ReplaceLast – Replace the last occurrence of a substring

‘ Replace the last occurrence of a stringFunction ReplaceLast(Expression As String, Find As String, ReplaceStr As String, _ Optional Compare As VbCompareMethod) As String Dim i As Long i = InStrRev(Expression, Find, , Compare) If i Then ‘ the search string is there ‘ note that the Replace function trims

Split – A replacement for VB6’s Split function under VB5

‘ A replacement for the Split function under VB4 and VB5” Note that the return value is a Variant that contains’ an array of stringsFunction Split(ByVal Text As String, Optional ByVal Delimiter As String = ” “, _ Optional ByVal Limit As Long = -1, Optional CompareMethod As _ VbCompareMethod

JoinQuote2 – A Join variant that works with 2-dimensional arrays and quoted strings

‘ Join variant that works with’ bi-dimensional arrays of any type’ and that encloses string values between quotes” ARR is the 2-dimensional array whose element must be joined’ ROWSEPARATOR is the separator for rows (default is CRLF)’ COLSEPARATOR is the separator fol columns (default is comma)’ QUOTED is the character

InStrRev – A replacement for VB6’s InStrRev under VB4 and VB5

‘ A replacement for the InStrRev function under VB4 and VB5” NOTE: uses the StrReverse functionFunction InStrRev(ByVal Text As String, Search As String, _ Optional ByVal Start As Long = -1, Optional ByVal CompareMethod As _ VbCompareMethod = vbBinaryCompare) As Long Dim Index As Long ‘ reverse the source strings,

Join – A replacement for VB6’s Join function under VB4 and VB5

‘ A replacement for the Join function under VB4 and VB5Function Join(arr() As String, ByVal Delimiter As String) As String Dim index As Long For index = LBound(arr) To UBound(arr) – 1 Join = Join & arr(index) & Delimiter Next Join = Join & arr(UBound(arr))End Function

Split2 – A Split variant that parses multiple lines of text

‘ A Split variant that parses a string that contains’ row and column separators, and returns a 2-dimensional array” the result String array has a number of columns equal’ to the highest number of fields in individual text linesFunction Split2(ByVal Text As String, Optional ByVal RowSeparator As String = _

JoinQuoted – A Join variant that encloses string values in quotes

‘ Join variant that works with arrays of any type’ and that encloses string values between quotes” ARR is the array whose element must be joined’ SEPARATOR is the separator char (default is comma)’ QUOTED is the character used to quote string values’ use a two-char string (eg “{}”) if

Filter – A replacement for VB6’s Filter function under VB5

‘ A replace for the Filter function under VB4 and VB5” Note that the source array is modified. For this reason’ this is declared as a Sub rather than a FunctionSub Filter(arr() As String, ByVal Search As String, Optional ByVal Include As _ Boolean, Optional ByVal CompareMethod As VbCompareMethod =

No more posts to show