Solved

VB.NET RTrim

Posted on 2009-04-15
3
1,357 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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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