\<bookmark_value\>Trim function\</bookmark_value\>

Trim Function

Removes all leading and trailing spaces from a string expression.

Syntax:


Trim( Text As String )

Return value:

String

Parameters:

\<emph\>Text:\</emph\> Any string expression.

Error codes:

5 Invalid procedure call

Example:


Sub ExampleSpaces
Dim sText2 As String,sText As String,sOut As String
    sText2 = " <*Las Vegas*> "
    sOut = "'"+sText2 +"'"+ Chr(13)
    sText = Ltrim(sText2) ' sText = "<*Las Vegas*> "
    sOut = sOut + "'"+sText +"'" + Chr(13)
    sText = Rtrim(sText2) ' sText = " <*Las Vegas*>"
    sOut = sOut +"'"+ sText +"'" + Chr(13)
    sText = Trim(sText2) ' sText = "<*Las Vegas*>"
    sOut = sOut +"'"+ sText +"'"
    MsgBox sOut
End Sub

Please support us!