Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
InStrRev issue
Can anyone tell me why the results of these are the same?
rsData.Fields("DataText") contains "Transaction Void #178" x = InStrRev(rsData.Fields("DataText"), "#") y = InStr(1, rsData.Fields("DataText"), "#") x and y both end up 18... I had expected that x would be 4. I also tried assigning the recordset value to a string "S" just to make sure ADO wasn't doing something strange to the string functions, still had the same results. I had to use the StrReverse() function in my Right$ function to get the "#178" extracted properly. Right$(rsData.Fields("DataText"), _ InStr(1, StrReverse(rsData.Fields("DataText")), "#")) 'returns "#178" -- Regards, John |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
InStrRev issue
Both InStr and InStrRev return the position of the found character counting
left to right. Since you have only a single occurrence of the '#' character, both InStr and InStrRev return the same value. InStrRev does not return the position counting right to left. Both InStr and InStrRev results are counting from the left. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "John Keith" wrote in message ... Can anyone tell me why the results of these are the same? rsData.Fields("DataText") contains "Transaction Void #178" x = InStrRev(rsData.Fields("DataText"), "#") y = InStr(1, rsData.Fields("DataText"), "#") x and y both end up 18... I had expected that x would be 4. I also tried assigning the recordset value to a string "S" just to make sure ADO wasn't doing something strange to the string functions, still had the same results. I had to use the StrReverse() function in my Right$ function to get the "#178" extracted properly. Right$(rsData.Fields("DataText"), _ InStr(1, StrReverse(rsData.Fields("DataText")), "#")) 'returns "#178" -- Regards, John |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help with Macro Using InStrRev: How to Rewrite to Use on Macs and | Excel Discussion (Misc queries) | |||
InstrRev Issue | Excel Discussion (Misc queries) | |||
Instrrev function | Excel Programming | |||
worksheet function for InStrRev() | Excel Programming | |||
InStrRev function not working? | Excel Programming |