InStr

G

gr

Hello, something I'm doing wrong in the followig statement:

intInString = VBA.InStr(aAvailable(inty),
strRowSourceSelected)

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

Thank you
 
G

Guest

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?
 
R

Rick Brandt

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?

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.
 
F

fredg

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?
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.
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?

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
 
G

gr

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
array as the strSearchFor??
The syntax i'm using:
varPos = InStr(aAvailable(inty), strRowSource)
thx
 
Top