Problem with start parameter of INSTR()

  • Thread starter Thread starter Fred Boer
  • Start date Start date
F

Fred Boer

Hello:

In an immediate window, I enter the following (with the results displayed).
Shouldn't the second example return "5", since I am using the "start"
parameter?

?instr("This is a test","a")
9
?instr(4,"This is a test","a")
9
?instr(4,"This is a test","a",vbTextCompare)
9
?instr(4,"This is a test","a",vbBinaryCompare)
9

Thanks!
Fred "Puzzled" Boer

Windows XP Pro
Access 2003
 
Fred,

The start parameter just specifies where to start the compare. The result
will still be the first found position (after start) within the entire
string.

HTH,
Josh
 
No, it's telling you that the first a appears at position 9 in the string.

?instr("Another test to find a in the string", "a")
1
?instr(4, "Another test to find a in the string", "a")
22

Here, it finds that the first "a" after position 4 is the 22nd character in
the string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top