- Home
·
- String Manipulation
·
- This sub sections out a substring from within the given string, starting at the given point, and en
This sub sections out a substring from within the given string, starting at the given point, and en
This sub sections out a substring from within the given string, starting at the given point, and ending at the given character as long as it
Rate This sub sections out a substring from within the given string, starting at the given point, and en
(1(1 Vote))
Dim inString As Boolean 'Set to True when inside
'quotation marks
Dim parNum As Integer 'Number of beginning
'parentheses found
inString = False
parNum = 0
'Loop around every character from the given start
For a = start To Len(str)
'If the end character is found
If Mid(str, a, Len(endStr)) = endStr Then
'If the end character isn't inside parentheses or quotes
If parNum = 0 And inString = False Then
Exit Function
End If
End If
'If a quote mark is found
If Mid(str, a, 1) = Chr(34) Then
'If we're inside quote marks, flag that we're not inside them
'anymore, otherwise flag that we're inside them now
If inString = False Then inString = True Else inString = False
End If
'If beginning parentheses are found outside of quote marks
If Mid(str, a, 1) = "(" And inString = False Then
'Increase number of parentheses
parNum = parNum + 1
'If end parentheses are found outside of quote marks
ElseIf Mid(str, a, 1) = ")" And inString = False Then
'Decrease number of parentheses
If parNum > 0 Then parNum = parNum - 1
End If
'Add the next character to the return string
GetString = GetString & Mid(str, a, 1)
Next a
End Function
This sub sections out a substring from within the given string, starting at the given point, and en Comments
No comments yet — be the first to post one!
Post a Comment