hello ppl
how can i check if a word is in the Sentence
the Sentence is "Micheal wrote 5 times"
i want to check whether "wrote" word is in the Sentence...
and if it contain that word, then add the Sentance to a listbox..
Printable View
hello ppl
how can i check if a word is in the Sentence
the Sentence is "Micheal wrote 5 times"
i want to check whether "wrote" word is in the Sentence...
and if it contain that word, then add the Sentance to a listbox..
If InStr("Micheal wrote 5 times", "wrote") > 0 Then 'it is found. If InStr returns 0 it was not found. Keep in mind it's case sensitive.
And of course that example is a bit pointless since strings were hardcode, you can of course use variables there or string type properties of objects/controls.
If this is a Chat program and, or, you have more than one reply in a text box separated by a new line, you may want to consider first using the Split function to assign each line in to an array index. This will make parsing with InStr and loading your listbox much easier to manipulate.