White Space in a string

  • Thread starter Thread starter Pete
  • Start date Start date
'Invalid characters in the beginning or end of a string
dim Invalids() as string = new string() {chr(9), chr(10), chr(13), " "}

'Base string
dim s as string = " " & chr(9) & "Some Text" & chr(9) & " "

'Trim spaces from the beginning of our base string
dim s1 as string = s.LTrim

'Trim the spaces from either end of our base string
dim s2 as string = s.Trim

'Trim invalid characters from the beginning of our base string
dim s3 as string = s.LTrim(Invalids)

'Trim the invalid characters from either end of our base string
dim s4 as string = s.Trim(Invalids)

'Write out our results
console.writeline(string.format("-{0}-, -{1}-, -{2}-, -{3}-",s1,s2,s3,s4))


HTH
 
Dim bla As String = " test "

bla = bla.TrimStart(" "c)



will result in a string containing "test "

regards



Michel Posseth
 
String's Trim method
NOTE: returns the trimmed string and doesnot trim the actual string.

HTH
rawCoder
 
Back
Top