i'm doing the ExtendedSplit() function. these function is for separe all words\strings\symbols:
sample:
int soma(int a,int b)
words(0)="int"
words(1)="soma"
words(2)="("
words(3)="int"
words(4)="a"
words(5)=","
words(6)="int"
words(7)="b"
words(8)=")"
(maybe i can do for strings and comments(or ignore comments);))
but can anyone tell me what i'm doing wrong please?
Code:
Public Function ExtendedSplit(ByVal Sentence As String) As String()
Dim lngSentencePos As Long
Dim lngStartWord As Long
Dim strWord() As String
Dim lngWordIndex As Long
For lngSentencePos = 1 To Len(Sentence)
If Mid(Sentence, lngSentencePos, 1) <> "" And lngStartWord = 0 Then
lngStartWord = lngSentencePos
ElseIf (Mid(Sentence, lngSentencePos, 1) = " " Or Mid(Sentence, lngSentencePos, 1) = "(" Or Mid(Sentence, lngSentencePos, 1) = "(" Or Mid(Sentence, lngSentencePos, 1) = "=" Or Mid(Sentence, lngSentencePos, 1) = "+" Or Mid(Sentence, lngSentencePos, 1) = """") And lngStartWord <> 0 Then
ReDim Preserve strWord(lngWordIndex + 1)
strWord(lngWordIndex) = Mid(Sentence, lngStartWord, lngSentencePos - 1)
Debug.Print strWord(lngWordIndex)
ReDim Preserve strWord(lngWordIndex + 1)
strWord(lngWordIndex) = Mid(Sentence, lngSentencePos, 1)
Debug.Print strWord(lngWordIndex)
lngStartWord = 0
End If
Next lngSentencePos
ExtendedSplit = strWord()
End Function
int soma(int a,int b)
words(0)="int"
words(1)="soma"
words(2)="("
words(3)="int"
words(4)="a"
words(5)=","
words(6)="int"
words(7)="b"
words(8)=")"
(maybe i can do for strings and comments(or ignore comments);))
but can anyone tell me what i'm doing wrong please?