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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|