Hello John, Marc, Barbara, et al.
This is part one of a possible answer to the question as I rephrased it.
How to remove trailing white space from a text field?
Simply put you will need to use some procedural language to do this.
I chose to use OO.oBasic for the moment.
With a standard installation of OO.o you will find the Basic library TOOLS.
In the TOOLS library is the Module STRINGS and in the STRINGS module the
function RTrimStr.
What I've done is taken the RTrimStr function and created a very similar
function RTrimElim as:
Function RTrimElim( ByVal BigString as string, ElimArray() as String) as
string
Dim i%
For i = 0 to Ubound(ElimArray)
do
BigString = RTrimStr(BigString, ElimArray(i))
loop until Instr(len(BigString) ,BigString, ElimArray(i)) = 0
Next
RTrimElim = BigString
End Function
What this function allows is for us to pass in a string and an array of
strings (in our case single character arrays) and then remove any of the
strings in the array from right side of the main string.
I then created a function RTrimWhiteSpace as:
function RTrimWhiteSpace( ByVal AString ) as string
dim tmpArry$(3)
dim tmpStr_in$
dim tmpStr_out$
tmpArry$(0) = chr(7)
tmpArry$(1) = chr(10)
tmpArry$(2) = chr(13)
tmpArry$(3) = chr(32)
tmpStr_in = AString
do
if tmpStr_out = "" then
tmpStr_out = tmpStr_in
else
tmpStr_in = tmpStr_out
end if
tmpStr_out = RTrimElim( tmpStr_in, tmpArry )
loop until len(tmpStr_in) = len(tmpStr_out)
RTrimWhiteSpace = tmpStr_out
end function
What I do here is define whitespace as TAB, SPACE, CARRIAGE RETURN, LINE
FEED characters. I do this by assigning the values to the variable
tmpArry$ using the CHR function.
Test the macros with this:
Sub Main
BasicLibraries.LoadLibrary("Tools")
tmpStr = "this is a test" + chr(13) + chr(13) + chr(7) + chr(10)
print len(tmpStr)
tmpStr = RTrimWhiteSpace(tmpStr)
print len(tmpStr)
print tmpStr
End Sub
which produces the following output
18
14
this is a test
Part two will be on how to call this function for each record in a table.
Till then,
Drew
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]