Solved

VB.NET RTrim

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual studio 2015 1 35
Need syntax help building hyperlink 2 41
VB.net Duplicating a table - primary key not created 3 38
VB.net VSTO Excel Ribbon error 4 13
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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