string.IndexOf method not working ...

  • Thread starter Thread starter JustMe
  • Start date Start date
J

JustMe

I'm trying the following:

dim str as string
dim loc as integer
str = "This is some (text)"
loc = str.IndexOf("(")

I would think that this should return a value of 13, but it returns zero.

Also, if I try doing the IndexOf method in the immediate window while
debugging I get a 'Parameter is incorrect' error.

Any ideas?
--Terry
 
Terry,

I have just tried your example using C# and it returns 13. It also returns
13 if I change the parameter from a string to a char, as in ...IndexOf(
'(' ), in other words, single quotes rather then double quotes. You might
try the single quotes in your VB code to see whether that affects the
result. Apart from that, I do not have any other answer.

Regards,
Neville Lang
 
Hi Neville ...

Thanks for the reply. This didn't work.

No matter what I try I get zero as the result in running code ... and if I
try to execute the code in the immediate window while debugging, I get the
'Parameter is incorrect' error.

Help?!

--Terry
 
By the way, when I run the exact same code in a desktop application, IndexOf
works as expected. I'm only having problems in CompactFramework apps.

Any ideas now?
--Terry
 
Never mind, I figured it out.

As a last resort, I thought I'd try HARD-Resetting my device and starting
from scratch.

It's working fine now. I'm guessing something went screwy-lewy when I
reverted back to SP1.

Thanks for the help.
--Terry
 
Back
Top