|
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 strTrim(ByVal MyStr As String, Optional strWhiteSpace) As String
' Procedure : strTrim
' Description: Remove user-nominated space from both ends of a string.
' Copyright: Chris Greaves Inc.
' Inputs: Data string, string of white-space characters
' Returns: Original string with white space removed.
' Assumes: None.
' Side Effects: None
' Tested: By the calls shown below.
Dim strWS As String
If IsMissing(strWhiteSpace) Then
strWS = strGetWhiteSpace
Else
strWS = strWhiteSpace
End If
While Len(MyStr) > 0 And InStr(1, strWS, Left(MyStr, 1))
MyStr = Right(MyStr, Len(MyStr) - 1)
Wend
While Len(MyStr) > 0 And InStr(1, strWS, Right(MyStr, 1))
MyStr = Left(MyStr, Len(MyStr) - 1)
Wend
strTrim = MyStr
'Sub TESTstrTrim()
'MsgBox "+" & strTrim(" abc ", Chr$(32) & Chr$(9) & Chr$(160)) & "+"
'MsgBox "+" & strTrim(" abc ", Chr$(9) & Chr$(160)) & "+"
'MsgBox "+" & strTrim(" abc ", "") & "+"
'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 |