InStr

message from gr on 4 Jun 2004
intInString = VBA.InStr(aAvailable(inty),
strRowSourceSelected)

intInString returns always 0 even when ther's a matching
string.

Thank you
 
anonymous replied to gr on 4 Jun 2004
Hello, I find out that InStr only works when the second
string is of length 1 - it only searches the first
character -
is there any equivalent that searches the whole word?

i Want to know if a string is already contained in another
example:

strSearchIn = "Hello;GoodBye;Hola;Adios;Gruzi;Tschus"
strSearchFor = "Adios"

I want to get a True or something to tell me that "Adios"
is on strSearchIn and a False to tell me that "Ciao" is
not int strSearchIn.

Any ideas?

statement:
 
Rick Brandt replied to anonymous on 4 Jun 2004
You are incorrect, The "string to be found" can be any length. Try this
in the debug window...

?InStr(1,"This is the string to search","the") <Enter>

The result is 9.
 
fredg replied to anonymous on 04 Jun 2004
Not True! InStr() searches the entire string from the first character
to the end, unless you specifically tell it to search from a different
start point.
See VBA Help for all the InStr() arguments.

Dim intX as Integer
Dim strSearchIn as String
strSearchIn = "Hello;GoodBye;Hola;Adios;Gruzi;Tschus"
intX = InStr(strSearchIn,"Adios")
If intX = 0 then
MsgBox "Not in string"
Else
MsgBox "In string"
End If
 
gr replied to fredg on 4 Jun 2004
ok, I thought that was the problem.
if I type the string in the immediate window works. But
not while code execution. Could it be because I'm using an
varPos = InStr(aAvailable(inty), strRowSource)
thx

first character
from a different
another
that "Adios"
 
Dirk Goldgar replied to gr on 4 Jun 2004
"gr" <anonymous@discussions.microsoft.com> wrote in message
news:182f301c44a31$e7a41680$a501280a@phx.gbl

I suggest you try dumping the parameter values to the Immediate Window
to see what's happening:

Debug.Print "available", aAvailable(inty)
Debug.Print "rowsource", strRowSourceSelected
intInString = VBA.InStr(aAvailable(inty), strRowSourceSelected)
Debug.Print intInString

You may find that the values aren't what you think they are.
 

Archived message: InStr (MS Access)