• 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
0
rocky050371
Asked:
rocky050371
1 Solution
 
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

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