|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function strStripRight(ByVal str As String, ByVal strDel As String)
' Procedure : strStripRight
' Description: Strip the rightmost portion of a string.
' Typical use - dropping the trailing subdirectory of a PATH.
' Copyright: Chris Greaves Inc.
' Inputs: Any string.
' String delimiter.
' Returns: An empty string if any error is detected.
' Assumes: Nothing
' Side Effects: None
' Tested: By the calls shown below.
Dim intStart As Integer ' Start at left, gets moved twoards the right
strStripRight = str ' Default value is the source string itself.
intStart = 1 ' Start at the Left, work all the way to the Right
While InStr(intStart + 1, str, strDel) > 0 ' Until we are at the Right
intStart = InStr(intStart + 1, str, strDel) ' Get the next Rightward delimiter
Wend
If intStart > 1 Then ' If we found more than one delimiter
strStripRight = Left(str, intStart - 1) ' drop the trailing directory
Else
End If
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |