|
1 members (Russ),
10,950
guests, and
1,516
robots. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
S |
M |
T |
W |
T |
F |
S |
|
|
|
1
|
2
|
3
|
4
|
5
|
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
|
27
|
28
|
29
|
30
|
31
|
|
|
|
|
This is another custom island. This one could be used for ads. This spot is one of the best places for ads on your site to be placed. This can be enabled/disabled on a per forum basis.
|
|
|
|
Joined: Dec 1999
Posts: 30,868
Master Elite Member
|
Public Function Str_ParseToSArr(ByVal MyString As String, Delimiter As String, AutoTrim As Boolean) As String()
'Purpose
' Used to parse elements in a string to a string array.
' The elements in the string are delimited by the specified delimiter.
'Parameters
' MyString (String) = The string we're parsing.
' Delimiter (String) = The first character in this string is used as the delimiter.
' If more than one characters exists, only the first character is used.
' AutoTrim (Boolean) = If True, all whitespace is trimmed in the returned array.
' If False, whitespace is honored and not removed at all.
'Return (String())
' Returns an array of String where each element contains an element from MyString.
' The elements are returned in the same order as they appear in MyString.
' All leading and trailing whitespace is removed from each element.
' Returns an empty array if:
' The specified string (MyString) contains no elements
' The specified delimiter (Delimiter) is zero-length
'Version History
' 1.0 3/30/2006 5:46am Tested by Russ Tanner on VB6 Win2000
'---
'Initiate variables
Dim X As String 'the current element in the loop
Dim D As String 'the normalized delimiter
Dim R() As String 'return buffer
'Trap: The specified delimiter is zero-length
If Len(Delimiter) = 0 Then
Str_ParseToSArr = R
Exit Function
End If
'Normalize the delimiter
D = Left(Delimiter, 1)
'Main parse loop
Do While True
'AutoTrim is enabled. We must remove leading/trailing whitespace before processing.
If AutoTrim Then MyString = Trim(MyString)
'Trap: No elements left to process, exit the loop now
If Len(MyString) = 0 Then Exit Do
'Get the next element and cut MyString...
'MyString contains a delimiter, use it to get the next element
If InStr(MyString, D) > 0 Then
X = Left(MyString, InStr(MyString, D) - 1)
MyString = Right(MyString, Len(MyString) - InStr(MyString, D))
'MyString does not have a delimiter, just get the whole rest of MyString
Else
X = MyString
MyString = ""
End If
'AutoTrim is enabled; Automatically trim each element
If AutoTrim Then X = Trim(X)
'Append a new element to the return buffer
ReDim Preserve R(ElementCount(R))
R(UBound(R)) = X
Loop
'Return the result
Str_ParseToSArr = R
End Function
|
|
|
|
|