Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21140

[RESOLVED] [VB6] - separe all words and symbols

$
0
0
i'm doing the ExtendedSplit() function. these function is for separe all words\strings\symbols:
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

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?

Viewing all articles
Browse latest Browse all 21140

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>