How do I find several occurances of the same string within a larger string?
I need some help to figure out how to find several occurrences of the same string within a larger string. I think I understand the VB6 command: Instr() as I have been successful in finding and highlighting the first of several strings within a string. But this is where I’m stumped! I don’t know how to write VB6 code to let me find the second, third, fourth string…etc. The code that I have used to find the first string is:
Private Sub cmdFind_Click()
Dim search, where
search = InputBox("Enter the text you want to find”)
where = InStr(Text1.Text, search)
If where Then
Text1.SelStart = where - 1
Text1.SelLength = Len(search)
MsgBox ("String not found")
For example, if the string was "Mississippi" and I wanted to search for all of the "i"’s and then highlight them one at a time or all at once; finding all the other occurrences of the same string in the larger string. Is there a way to do it in VB6? I'm sure there is, but I don't know how.
I guess another way to describe what I'm getting at is to use Microsoft’s Notepad as an example. I have a fair amount of text in the notepad, and at times I want to find a certain word, so I use the Find command. It will find the first occurrence of the word, and if there are other occurrences it continues and highlights each occurrence of the word until the end of the text is reached.
If anyone out there can help me with the code, I’d be very appreciative.
I thank who ever is able to help in advance.