Dim MyString,OutString As String, i As Int
MyString = " this is a test "
i = MyString.Length -1 ' i equals the last character position of the string
Do While MyString.CharAt(i)=" " 'if the charater is A space then
OutString = MyString.SubString2(0, i) 'make the output string equal the string without the last character
i=i-1
Loop
If OutString<>"" Then MyString = OutString
Log("'" & MyString & "'")
Msgbox(MyString,"") ' displays MyString (this is a test) without any spaces