|
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 strSplitStringAt(strIn As String, strDelim As String, boolDirection As Boolean)
' Procedure : strSplitStringAt
' Description: Return the leading or trailing portion of a string.
' Copyright: Chris Greaves Inc.
' Inputs: A string.
' A delimiter character.
' A directional flag True==>leading string
' Returns: A sub-string of the original string.
' Assumes: None.
' Side Effects: None.
' Tested: By the calls shown below.
' If the delimiter is found TRUE returns the first sub-string
' If the delimiter is found FALSE returns all but the first sub-string
' If the delimiter is not found TRUE returns the original string
' If the delimiter is not found FALSE returns the empty string
Dim lngI As Long
If strDelim = "" Then
strSplitStringAt = ""
Else
lngI = InStr(1, strIn, Left(strDelim, 1))
If lngI > 0 Then
If boolDirection Then
strSplitStringAt = Left(strIn, lngI - 1)
Else
strSplitStringAt = Right(strIn, Len(strIn) - lngI)
End If
Else
If boolDirection Then
strSplitStringAt = strIn
Else
strSplitStringAt = ""
End If
End If
End If
'Sub TESTstrSplitStringAt()
'MsgBox strSplitStringAt("here,is,a,string", ",", True) ' "here"
'MsgBox strSplitStringAt("here,is,a,string", ",", False) ' "is,a,string"
'MsgBox strSplitStringAt("string", ",", True) ' "string"
'MsgBox strSplitStringAt("string", ",", False) ' ""
'End Sub
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 |