• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

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
1 Solution
Jorge PaulinoIT Pro/DeveloperCommented:
But that way you will fill the sDescription with 100 empty chars.
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!?
Jorge PaulinoIT Pro/DeveloperCommented:
Can you explain us better what you need to do
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
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)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now