White Space in a string

A

AMDRIT

'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
 
M

m.posseth

Dim bla As String = " test "

bla = bla.TrimStart(" "c)



will result in a string containing "test "

regards



Michel Posseth
 
R

rawCoder

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

HTH
rawCoder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top