473,378 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Instr from right

I use the instr function frequently to find particular characters
within a string and manipulate them eg all characters to the left of a
particular character.
If I understand correctly, Instr finds the first occurence of the
nominated characater starting from the left of the subject field. Is
there a way to do this but starting from the right of the field
TIA
Jun 27 '08 #1
3 14822
On May 20, 6:55*pm, Steve <stevecox4...@gmail.comwrote:
I use the instr function frequently to find particular characters
within a string and manipulate them eg all characters to the left of a
particular character.
If I understand correctly, Instr finds the first occurence of the
nominated characater starting from the left of the subject field. *Is
there a way to do this but starting from the right of the field
TIA
From:
http://chrisrae.com/vba/routines/revinstr.html
---------------------------------------
Routine: RevInStr
Parameters: findin As String, tofind As String
Description: Find a character in a string, only backwards

Function RevInStr(findin As String, tofind As String) As Integer
' Chris Rae's VBA Code Archive - http://chrisrae.com/vba
Dim findcha As Integer
For findcha = Len(findin) - Len(tofind) + 1 To 1 Step -1
If Mid(findin, findcha, Len(tofind)) = tofind Then
RevInStr = findcha
Exit Function
End If
Next findcha
' Defaults to zero anyway (tsk, tsk, etc)
End Function
---------------------------------------
Jun 27 '08 #2
On Tue, 20 May 2008 18:55:01 -0700 (PDT), Steve wrote:
I use the instr function frequently to find particular characters
within a string and manipulate them eg all characters to the left of a
particular character.
If I understand correctly, Instr finds the first occurence of the
nominated characater starting from the left of the subject field. Is
there a way to do this but starting from the right of the field
TIA
Access 2000 or newer?
Look up the InStrRev() function in VBA help.

?InStrRev("This is my place"," ")
11

?Mid("This is my place",InStrRev("This is my place"," ")+1)
place
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 27 '08 #3
On Tue, 20 May 2008 18:55:01 -0700 (PDT), Steve
<st**********@gmail.comwrote:

In recent versions of Access you can use the InstrRev function,
-Tom.

>I use the instr function frequently to find particular characters
within a string and manipulate them eg all characters to the left of a
particular character.
If I understand correctly, Instr finds the first occurence of the
nominated characater starting from the left of the subject field. Is
there a way to do this but starting from the right of the field
TIA
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DTB | last post by:
I am trying to convert a complex function from Oracle to SQL Server and have come across Oracle's Instr() function. I see SQL Server has CHARINDEX() which is similar, however it does not provide...
4
by: Gordon | last post by:
Hi; I am trying to extract a substring using a combination of the mid() and Instr() i.e. aString = "Jones, Thomas R, Dr." hold = InStr(1, aString, " ," , 1) newString = Mid(aString, 1,...
4
by: fischerspooner | last post by:
Hi, I'm banging my head against the desk because I can't find a solution for the following simple problem. Case: There is a column in a table that has FamilyName and FirstName(s) in one field....
3
by: Anil Gupte | last post by:
I must have missed it. It cannot be possible. Or may be I am living in the past of my lisp programming days. There must be a function to find the nth occurrence of a string within another. ...
12
by: rodchar | last post by:
hey all, i'm getting a result that i don't understand i have a string "test1, test2" If InStr("test1") and InStr("test2") Then 'Inside EndIf The inside is not running for some reason. Any...
3
by: lstrudeman | last post by:
Hello; A friend gave me this syntax and they are unavailable at the moment and I need this asap. I am trying to figure out how SQL figures this out. Below the syntax takes a field in a file and...
3
by: Kubie | last post by:
I'm having problems finding the syntax/comands that do the this correctly. I'm must not be doing the join right or something.. List one AAC1234 CDA2w31 12ZZC12 12TRE1 23234 243
3
by: Alex Pavluck | last post by:
I have a date stored like this '2004 - 2006' and I use this code to get startyear and stopyear StartYear: Trim(Left(,InStr(,"-")-1)) StopYear: Trim(Right(,InStr(,"-")-1)) Is there a way to...
13
colinod
by: colinod | last post by:
I have a page that uses a session variable that stores items like a shopping cart, all this works fine but i am trying to code a button that removes an item, i have a page that i have set up for the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.