Trim or LTrim() will delete blanks but not special chars.
There are many ways to do this, one is searching for the first char higher than 32 in the asccii code list, then removing all chars at left, example:
Usage:Code:Private Function RemoveInvalidChars(ByRef pStr As String) As String Dim i As Long, lLastInvalidChar As Long If LenB(pStr) = 0 Then Exit Function For i = 1 To Len(pStr) If Asc(Mid(pStr, i, 1)) > 32 Then lLastInvalidChar = i - 1 Exit For End If Next RemoveInvalidChars = Right(pStr, Len(pStr) - lLastInvalidChar) End Function
Code:Text1.Text = RemoveInvalidChars(Text1.Text)




Reply With Quote