This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.
This version is copyright and may only be used for local testing purposes. It may not be distributed.
Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.
Description
Return a copy of a string with leading and trailing characters removed.
Syntax
s = TRIM$(MainString [, [ANY] MatchString])
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
MainString |
String |
No |
String expression to check |
MatchString |
String |
Yes |
If MatchString is not specified, TRIM$ removes leading and trailing spaces.
If the ANY keyword is included, MatchString specifies a list of single characters to be searched for individually - a match on any one of which as a trailing character will cause the character to be removed from the result. |
Remarks
TRIM$ combines the functionality of LTRIM$ and RTRIM$ into a single function.
Restrictions
TRIM$ is case sensitive, so capitalization matters.
See also
String Handling, TRIMFULL$, LTRIM$, RTRIM$,
Examples
Thanks to Abraxas for the following script example
' Usage of the LTRIM$ Keyword example
' Usage of the RTRIM$ Keyword example
' Usage of the TRIM$ Keyword example
' Usage of the TRIMFILL$ Keyword
Dim MyOLDString As String VALUE "HELLO WORLD"
Dim MyOLD2String As String VALUE " A B C D E F "
Dim MyLTRIMString As String
Dim MyRTRIMString As String
Dim MyTRIMString As String
Dim MyTRIMFULLString As String
Dim sMsg As String
MyLTRIMString = LTRIM$(MyOLDString, Any "HELLO")
MyRTRIMString = RTRIM$(MyOLDString, Any "WORLD")
MyTRIMString = TRIM$(MyOLDString , Any "HEL")
MyTRIMFULLString = TRIMFULL$(MyOLD2String)
sMsg += "Normal " & MyOLDString & $CRLF & $CRLF
sMsg += "LTRIM$ " & MyLTRIMString & $CRLF & $CRLF
sMsg += "RTRIM$ " & MyRTRIMString & $CRLF & $CRLF
sMsg += "TRIM$ " & MyTRIMString & $CRLF & $CRLF
sMsg += "TRIMFULL$ " & MyTRIMFULLString & $CRLF & $CRLF ' spaces removed
MSGBOX 0, sMsg