Page 1 of 1

Using instr and other functions like it

Posted: Tue Dec 11, 2007 3:34 pm
by mmurdock
How would I use instr and other such functions in a form. Whenever I try it get errors such as 'InStr' is not a member of 'String'

Thanks,

Mat

Using instr and other functions like it

Posted: Tue Dec 11, 2007 7:12 pm
by Brendan
You can use String.IndexOf() method to replace the InStr function.
You should be able to use any of the string functions to manipulate a string like Substring, Trim, LastIndexOf etc..

Using instr and other functions like it

Posted: Wed Dec 12, 2007 11:42 pm
by mmurdock
If I do something like this:

dim sample as string = "12-34"

textbox1.text = Instr(sample, "-")


I get this as an error: "Name 'Instr' is not declared."

Using instr and other functions like it

Posted: Thu Dec 13, 2007 4:04 am
by Brendan
To use the old VB functions you will need to switch to your Code Tab and add the following line to the end of the Imports list

Code: Select all

Imports Microsoft.VisualBasic

Using instr and other functions like it

Posted: Thu Dec 13, 2007 9:48 am
by mmurdock
Hey! that worked!

Thanks!!!!

Mat