[AccessD] Last occurrence within a string

Vincent Pusateri vchas at artronix-solutions.com
Tue Oct 26 10:44:43 CDT 2004


Here you go

Public Function GetEndString(vntString As Variant, strSymbol As String) As
String

    Dim intStartPosition As Integer
    Dim intSymbolPosition As Integer
    
    ' Loop through the line, looking for the last occurrence
    ' of the symbol.  Once the last symbol as been found, pass
    ' back the string to the right of it.
    
    intStartPosition = 1
    
    Do
        intSymbolPosition = InStr(intStartPosition, vntString, strSymbol)
        If intSymbolPosition > 0 Then
            intStartPosition = intSymbolPosition + 1
        End If
    Loop Until intSymbolPosition = 0
    
    GetEndString = Trim$(Mid(vntString, intStartPosition))
   
End Function 

Vinnie Chas

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of ACTEBS
Sent: Tuesday, October 26, 2004 7:08 AM
To: Access Group (E-mail)
Subject: [AccessD] Last occurrence within a string

Guys,

I am stuffing around with this and am sure I have done this before but for
the life of me can't get it. I need to find the last occurrence of "\"
within a file path string. For example if the path was
C:\MyDocs\Docs\Temps\Hello.doc I want to be able to return the Hello.doc
portion and to do that obviously I need to know what position the last
backslash is.

Any ideas?

Vlad
--
_______________________________________________
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