A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

InStr



 
 
Thread Tools Display Modes
  #1  
Old June 4th, 2004, 01:46 PM
gr
external usenet poster
 
Posts: n/a
Default InStr

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
  #2  
Old June 4th, 2004, 02:22 PM
external usenet poster
 
Posts: n/a
Default InStr

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?

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

  #3  
Old June 4th, 2004, 02:30 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default InStr

wrote in message
...
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.



--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



  #4  
Old June 4th, 2004, 02:57 PM
fredg
external usenet poster
 
Posts: n/a
Default InStr

On Fri, 4 Jun 2004 06:22:57 -0700,
wrote:

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
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
  #5  
Old June 4th, 2004, 03:05 PM
gr
external usenet poster
 
Posts: n/a
Default InStr

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


-----Originalnachricht-----
On Fri, 4 Jun 2004 06:22:57 -0700,
wrote:

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
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.

  #6  
Old June 4th, 2004, 07:41 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default InStr

"gr" wrote in message

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


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.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #7  
Old June 6th, 2004, 09:10 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default InStr

The argument got to be a String, NOT an array (of Strings).

--
HTH
Van T. Dinh
MVP (Access)


"gr" wrote in message
...
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




  #8  
Old June 6th, 2004, 12:08 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default InStr

But he's passing aAvailable(inty), so in other words it is just a string,
not an array.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Van T. Dinh" wrote in message
...
The argument got to be a String, NOT an array (of Strings).

--
HTH
Van T. Dinh
MVP (Access)


"gr" wrote in message
...
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






  #9  
Old June 7th, 2004, 12:15 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default InStr

Thanks, Doug.

I read more into his text and missed his example.

--
HTH
Van T. Dinh
MVP (Access)




"Douglas J. Steele" wrote in message
...
But he's passing aAvailable(inty), so in other words it is just a string,
not an array.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.