NationStates Jolt Archive


VB code

Klonor
14-04-2005, 23:37
Oy, I am way out of pratice. Shameful! It's been so long since I've edited any of the VB programs that I've made (and I've made quite a few) that I'm beginning to forget the language. Drat!

Anyway, I have a question for people more in practice. If you have a text box, with text in it, how do you program it to determine if one specific word (or sequence of words) is in that box? I know how to check if all the text matches something else (If text1.text = "XXXXX" then XXXX) but what if you just want to know about one word that might or might not be in the text?
Carrot Tops
14-04-2005, 23:39
www.planetsourcecode.com

^ ask your question there theres a lot of geniuses there
Calricstan
14-04-2005, 23:52
I think there's an InStr method in VB which returns the position of the first occurence of one string within another. So you'd do something like:

if InStr(text1.text, "wibble") > 0 then
// 'wibble' is contained within the text
else
// it isn't
end if
Klonor
14-04-2005, 23:59
So, I could just copy/past that code (replacing wibble with my own word, of course), and it'll work? Thanks
Klonor
15-04-2005, 00:05
It works! w00t! Thanks