Hello team,
I have hard time to understand this result:
Instr(10, "Tech on the Net", "t")
Result 15, I think it should be 5, the start position is 10, the text being searched is: Tech on the Net, search item is: "t"
Why the result is 15
======================================
Same with InstrRev
InstrRev ("alphabet", "a")
Result 5
InstrRev("alphabet", "a", -1)
Result 5
InstrRev ("alphabet", "a", 1)
Result 1
InstrRev ("alphabet", "a", 2)
Result 1
InstrRev ("alphabet", "a", 3)
Result 1
InstrRev ("alphabet", "a", 4)
Result 1
InstrRev ("alphabet", "a", 7)
Result 5
===================================
And also compare argument in this function: -1, 0, 1, 2, I only understand option 1.
==================================================
dictionary.doc
Left([Filename],InstrRev([Filename],".")-1) Returns dictionary. How? InstrRev((filename),".")-1 brings 3 and from left only 3 characters brings dic.
Am I wrong? What is that I fail to see?
Regards,
BittenApple
Instr and InstrRev Functions in Access
-
- BronzeLounger
- Posts: 1498
- Joined: 01 Mar 2015, 02:03
-
- Administrator
- Posts: 78658
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Instr and InstrRev Functions in Access
InStr searches from the position specified in the first argument, but it always returns the position from the start of the string.
Similarly, InStrRev starts searching backwards from the position specified in the third argument (if available), but it always returns the position from the start of the string.
The Compare argument determines how the strings are compared.
If you specify vbUseCompareOption = -1, the comparison uses the method specified by the Option Compare line at the top of the module.
If you specify vbBinaryCompare = 0, strings must be exactly the same. B is not the same as b, and é is not the same as e.
If you specify vbTextCompare = 1, comparison is case insensitive: B is the same as b, but é is not the same as e.
If you specify vbDatabaseCompare = 2 (available in Access only), comparison is according to the locale settings. In French, for example, e would be treated the same as é.
In your last example, InstrRev([Filename],".") returns 11 - again since the position is counted from the start, so InstrRev([Filename],".")-1 equals 10.
Similarly, InStrRev starts searching backwards from the position specified in the third argument (if available), but it always returns the position from the start of the string.
The Compare argument determines how the strings are compared.
If you specify vbUseCompareOption = -1, the comparison uses the method specified by the Option Compare line at the top of the module.
If you specify vbBinaryCompare = 0, strings must be exactly the same. B is not the same as b, and é is not the same as e.
If you specify vbTextCompare = 1, comparison is case insensitive: B is the same as b, but é is not the same as e.
If you specify vbDatabaseCompare = 2 (available in Access only), comparison is according to the locale settings. In French, for example, e would be treated the same as é.
In your last example, InstrRev([Filename],".") returns 11 - again since the position is counted from the start, so InstrRev([Filename],".")-1 equals 10.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1498
- Joined: 01 Mar 2015, 02:03
Re: Instr and InstrRev Functions in Access
Thank for all the explanation!