How do I write this substring code in Visual Basic?
Robert Nesta M asked:
I am writing a Visual Basic program, and I’m wondering what to do.
I want to write an if/then statement, where IF a certain substring is contained anywhere in a string variable, THEN this certain event will execute. But I’m not sure how to do that. Help?
Related posts:
- Can i write BASIC or VISUAL BASIC programs on the internet? buckbucknumber2000 asked: I’d like to be able to write a...
- question for visual basic for calculate the sum of the number digits? ymdian asked: Write a Visual Basic program that will take...
- how to make a visual basic program to record a 2 pin connection on a serial port? baseballman999 asked: I run a retail store and i would...
- Can you give me the code for a cool program for Visual basic 2008? spongebob asked: Ok i got visual basic 2008 express edition...
- Visual Basic? Yahoo Manager asked: How would I write a visual basic...
Filed Under Programming & Design |
Tagged With Visual Basic Program, Writing Program
Comments
One Response to “How do I write this substring code in Visual Basic?”
instr(1,”Today is a nice day.”,”nice”,vbTextCompare )
use instr
1 ==> position to start search
“Today is a nice day.” ==> String you want to search in
“nice” ==> String you are searching
vbTextCompare ==> compare type, text means ignore case
you can coose from binary and database compare
Return value is 0==> means not found and actual position of search string if found.
So you will be using
IF instr()0 then ==> if the string is found