[AccessD] InStrRev was... Parsing Strings-UPDATE

Marcus, Scott (GEAE, RHI Consulting) scott.marcus at ae.ge.com
Tue Feb 4 09:37:00 CST 2003


Sorry, sent untested code this one works....

Public Function InStrRev(strSearch As String, strFind As String) As Integer
     Dim intLastOccurance As Integer
     Dim intPosition As Integer

     intLastOccurance = 0
     intPosition = InStr(1, strSearch, strFind)

     While intPosition > 0
          intLastOccurance = intPosition
          intPosition = InStr(intPosition + 1, strSearch, " ")
     Wend

     InStrRev = intLastOccurance
End Function


Watch for Line wrap.

Scott Marcus

-----Original Message-----
From: Marcus, Scott (GEAE, RHI Consulting)
[mailto:scott.marcus at ae.ge.com]
Sent: Tuesday, February 04, 2003 10:22 AM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Parsing Strings-UPDATE


Here is an all purpose function that returns 0 if the string doesn't contain
what you are looking for... and the position of the last occurance otherwise.

Watch for line wrap...

Public Function LastOccurance(strSearch as String, strFind as String) as Integer
     Dim intLastOccurance as Integer
     Dim intPosition as Integer

     intLastOccurance = 0
     intPosition = Instr(1, strSearch, strFind)

     While intPosition > 0
          intLastLastOccurance = intPosition
          intPosition = Instr(intPosition, strStart, " ")
     Wend

     LastOccurance = intLastOccurance
End Function

Scott Marcus

-----Original Message-----
From: Bryan Carbonnell [mailto:carbonnb at sympatico.ca]
Sent: Tuesday, February 04, 2003 9:37 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Parsing Strings-UPDATE


On 4 Feb 2003 at 8:19, Terri Jarus wrote:

> This was exactly what I needed.  However, InStrRev is not available in
> 97 - I have both 97 and XP, so was able to extract what I needed.  How
> would it work for 97 though??

Terri,

You would have to loop through the string one character at a time, 
backwards to find the space and then parse it, something like:

For lngLoop = Len(strStart) To 1 Step -1
  If Mid$(strStart, lngLoop, 1) = " " Then
    'We have the space so exit the loop
    Exit For
  End If
Next

strOut = Mid$(strStart, lngLoop + 1)

--
Bryan Carbonnell - carbonnb at sympatico.ca
Experience is a wonderful thing. It enables you to recognize a 
mistake when you make it again.


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list