Trim not trimming? 
Author Message
 Trim not trimming?

Can somebody explain me why Trim does not removes "B" and "2" chars from
sTxt string?

  Dim sTxt As String = "ABCD123E"
  Dim aChars() As Char = {"B"c, "2"c}
  Dim sRes As String = sTxt.Trim(aChars)
  Debug.WriteLine(sRes)

TIA
Corrado



Sun, 26 Sep 2004 16:00:17 GMT  
 Trim not trimming?
Corrado,

The Trim method only works on the outermost characters of a string. Once it
gets to a character that isn't supposed to be trimmed then it stops
searching. Change your string to "BBB2BBBABCD123E222B222" and you'll see
what I mean.

If you want to remove a character then use the Replace() method.
Dim sRes As String = sTxt.Replace("B","")

--
Moving from VB6 to VB.NET?  It just got easier...
"The .NET Languages: A Quick Translation Guide"
www.bischofsystems.com/vbnet.asp


Quote:
> Can somebody explain me why Trim does not removes "B" and "2" chars from
> sTxt string?

>   Dim sTxt As String = "ABCD123E"
>   Dim aChars() As Char = {"B"c, "2"c}
>   Dim sRes As String = sTxt.Trim(aChars)
>   Debug.WriteLine(sRes)

> TIA
> Corrado



Sun, 26 Sep 2004 16:28:18 GMT  
 Trim not trimming?
Thanks Brian, i didn't understood what exactly trim stands for.

Corrado



Sun, 26 Sep 2004 17:49:05 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Difference between trim and trim$

2. Trim() vs Trim$(), etc

3. Equivalent functionality to trim - but with a differenct character set trimmed

4. Trim vs Trim$

5. Trim Function Not Recognized?

6. .Trim and .TrimEnd do not strip chr(0)!

7. String.Trim does not strip

8. String.Trim not working?

9. Trim not removing 0 bytes

10. trim() function not working in internet explorer 6

11. Trim() command not working properly

12. Trim not working?

 

 
Powered by phpBB® Forum Software