by SirCodezAlot (2 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sun 25th August 2002
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
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
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
No comments have been posted about This sub sections out a substring from within the given string, starting at the given point, and en. Why not be the first to post a comment about This sub sections out a substring from within the given string, starting at the given point, and en.