Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Trimming strings

Total Hit ( 3127)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Visual Basic .NET strings expose three trim methods: TrimStart, TrimEnd, and Trim - which trim one or more characters from the beginning, the end, or both the beginning and end of the string. They therefore work like VB6's LTrim, RTrim, and Trim functions, with an important difference: you can decide which characters are to be trimmed. For example, in many cases you want to trim not just spaces, but also tabs and CR-LF pairs. Here's the compact VB.NET solution:

Click here to copy the following block
' S is the string to be trimmed.
Dim cArr() As Char = { " "c, Chr(9), Chr(13), Chr(10) }
s = s.TrimStart(cArr)

You can use the same pattern with TrimEnd and Trim, of course.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.