Text Trimming

I have the following

           Dim sDescription As New String(" "c, 100)
     
A value is assigned to the string, I effectively want to chop off anything that is not used for exmaple if only 10 characters are assigned to sdescription then the new description should be length 10
rocky050371Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
But that way you will fill the sDescription with 100 empty chars.
0
ReecioCommented:
Cant you just use "Dim sDescription As String" ?
It makes it variable in length but has to be set a value otherwise its $null.
I think using New String doesnt restrict the string length anyway, as when you set a new string to it I think it resizes!?
0
Jorge PaulinoIT Pro/DeveloperCommented:
Can you explain us better what you need to do
0
rocky050371Author Commented:
I have to pass the string by reference to a dll , therefore it needs to be 100, the result is the same string
0
DodgyRefCommented:
sDescription = sDescription.TrimEnd(" "c) will remove all spaces from the end of the variables value.

sDescription = sDescription.TrimEnd will remove all whitespace characters from the end (e.g. New Line, Carriage Return, Space, Tab)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.