Solved

VB.NET RTrim

Posted on 2009-04-15
3
1,354 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
Comment Utility
TrimEnd = RTrim
TrimStart = LTrim
0
 
LVL 11

Author Comment

by:bmatumbura
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now