Below you'll find the source for the Visual Basic 6 function RealTrim.
Attribute VB_Name = "modRealTrim"
' This function is downloaded from:
' http://www.stefanthoolen.nl/archive/vb6-functions/
'
' You may freely distribute this file but please leave all comments, including this one, in it.
'
' @Author Stefan Thoolen <mail@stefanthoolen.nl>
Option Explicit
''
' Trims all kind of whitespaces
' The VB6 trim() function only removes spaces, this function also removes null-chars, tabs, returns and linefeeds
' @param String txt The input text
' @return String The trimmed output text
' @author Stefan Thoolen <mail@stefanthoolen.nl>
Public Function RealTrim(ByVal txt As String) As String
Do
If Len(txt) = 0 Then
Exit Do
ElseIf Left(txt, 1) = Chr(0) Or _
Left(txt, 1) = vbTab Or _
Left(txt, 1) = " " Or _
Left(txt, 1) = vbCr Or _
Left(txt, 1) = vbLf Then
txt = Right(txt, Len(txt) - 1)
ElseIf Right(txt, 1) = Chr(0) Or _
Right(txt, 1) = vbTab Or _
Right(txt, 1) = " " Or _
Right(txt, 1) = vbCr Or _
Right(txt, 1) = vbLf Then
txt = Left(txt, Len(txt) - 1)
Else
Exit Do
End If
Loop
RealTrim = txt
End Function