|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
Public Function StrA_Mid(StrA() As String, ByVal Start As Long, ByVal Length As Long) As String()
'Purpose
' Used to parse all elements of a string array using the same method as the VB function mid().
'Parameters
' StrA (String()) = The string array we're working with.
' Start (Long) = The starting position to parse each element.
' The first character of a string is considered position 1.
' If this is 0 (zero) or negative, 1 is assumed.
' If this number is greater than the number of characters in the string,
' the particular element will be assigned a zero-length string.
' Length (Long) = The number of characters to parse from each element beginning at Start.
' If this is 0 (zero) or negative, 0 (zero) is assumed. This will return all elements as zero-length.
' If this is higher than the number of characters remaining in an element,
' all characters from Start to the end of the string are assigned to the particular element.
'Return (String())
' Returns the specified string array (StrA) with each element parsed according to the values specified.
' Returns an empty string array if:
' - The specified array (StrA) is empty.
'Version History
' 1.0 6/7/2007 3:48am Tested by Russ Tanner on VB6 SP5 Win2K Pro SP4.
'---
'Initiate variables
Dim i As Long 'iterator
Dim r() As String 'return buffer
'Trap: The specified array is empty, return an empty array
If Arr_IsEmpty(StrA) Then
StrA_Mid = r
Exit Function
End If
'Filter Error Condition: Start is zero or negative. Change this value to 1.
If Start <= 0 Then Start = 1
'Filter Error Condition: Length is negative. Change it to zero.
If Length < 0 Then Length = 0
'Transfer the specified array to the output buffer
r = StrA
'Main Loop: Loop through each element of the specified array, trimming each element
For i = LBound(r) To UBound(r)
r(i) = Mid(r(i), Start, Length)
Next i
'Return the result
StrA_Mid = r
End Function
|
|
|
|
Entire Thread
|
Used to parse all elements of a string array using the same method as the VB function mid().
|
Russ
|
08/11/08 10:34 PM
|
|
|
|