Solved

VB.NET RTrim

Posted on 2009-04-15
3
1,360 Views
Last Modified: 2012-05-06
Dear Experts,

In VB.NET, there is this function:

String.Trim(array<Char>)

which removes all leading and trailing occurrences of a set of characters specified in an array from the current String object.

It looks like there are no RTrim and LTrim equivalents. I need function

RTrim(array<Char>)

that removes the specified array of characters from the end of a string.
0
Comment
Question by:bmatumbura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:JPJ78
ID: 24146767
TrimEnd = RTrim
TrimStart = LTrim
0
 
LVL 11

Author Comment

by:bmatumbura
ID: 24146876
JPJ78:

The LTrim function only strips leading spaces and the RTrim function only strips trailing spaces from a string variable.

I want a function that not only strips SPACES but also other characters like what the String.Trim function does. For example:

RTrim("boxter8366#", "#")

should return: "boxter866"

and

RTrim("boxter8366#", "#6")

should return: "boxter83"
0
 
LVL 10

Accepted Solution

by:
JPJ78 earned 250 total points
ID: 24146911
TrimEnd and TrimStart takes an characterarray as a parameter.
Dim str As String = "boxter8366#"
str.TrimEnd(New Char() {"#"c}) 'Result: "boxter866"
 
str.TrimEnd(New Char() {"6"c, "#"c}) ' Result: "boxter83"

Open in new window

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question