Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InStrRev() Question

Status
Not open for further replies.

Melagan

MIS
Nov 24, 2004
443
US
I was trying to use this function to help in another thread earlier and ran into an interesting problem....check this data out:


SQL:
Code:
SELECT tblAddresses.Address
, InStrRev([Address],"APT") AS MyInstrRev
, InStr([Address],"APT") AS MyInstr

FROM tblAddresses;

RESULT:
Code:
Address                          MyInstrRev   MyInstr
1234 Main St. APT a1             15           15
154 G Avenue APT 1B              14           14
10 AB Street                      0            0
16342 Brawley Avenue APT 203     22           22
1 John Way APT 1                 12           12

Should'nt the InstrRev column start counting from the END of the string back towards the beginning? I'd expect the first row to have a MyInstrRev value of 6, not 15. What gives?

~Melagan
______
"It's never too late to become what you might have been.
 
When in VBE (Alt+F11) open the debug window (Ctrl+G), type instrrev and press the F1 key.
The InStrRev function start the SEARCH from the end of the string back towards the beginning but returns the ordinal position of the match just like InStr.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I understand, so if you'd want to use it if you had something like this:

"Test 112 Data_Crunch 112 51"

and you wanted to return a LONG Integer for the second 112's position, you'd use InStrRev(), and InStr() for the first 112's position. Cool deal; thank you sir!

~Melagan
______
"It's never too late to become what you might have been.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top