473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Visual Basic 2008 - Trim ?

Hey all,

I need to trim the first couple of letters from a string and stop a
particular character.

Here is some code for example:

DN = "CN=username,OU=computers,OU=abingdon, OU=MAR,
OU=Customers,DC=company,DC=com"

I need to get rid of just the "CN=username," part (note that i need to
get rid of the " , " also)

I ran across an article that talks about trim() but dont know how that
would work since the usernames will be different every time.

help ?
Oct 3 '08 #1
5 4019
On Oct 3, 1:03*pm, brett <planetbr...@gmail.comwrote:
Hey all,

I need to trim the first couple of letters from a string and stop a
particular character.

Here is some code for example:

DN = "CN=username,OU=computers,OU=abingdon, OU=MAR,
OU=Customers,DC=company,DC=com"

I need to get rid of just the "CN=username," part (note that i need to
get rid of the " , " also)

I ran across an article that talks about trim() but dont know how that
would work since the usernames will be different every time.

help ?
Assuming VB.NET:

DB = DB.Replace("CN=username,", "")
Oct 3 '08 #2
brett wrote:
Hey all,

I need to trim the first couple of letters from a string and stop a
particular character.

Here is some code for example:

DN = "CN=username,OU=computers,OU=abingdon, OU=MAR,
OU=Customers,DC=company,DC=com"

I need to get rid of just the "CN=username," part (note that i need to
get rid of the " , " also)

I ran across an article that talks about trim() but dont know how that
would work since the usernames will be different every time.

help ?
The trim method is used to trim off specific characters, for example
trimming off leading and trailing spaces.

Use the IndexOf method to get the location of the first comma, then use
the Substring method to get the part of the string after the comma.

--
Göran Andersson
_____
http://www.guffa.com
Oct 3 '08 #3
On 2008-10-03, brett <pl*********@gmail.comwrote:
Hey all,

I need to trim the first couple of letters from a string and stop a
particular character.

Here is some code for example:

DN = "CN=username,OU=computers,OU=abingdon, OU=MAR,
OU=Customers,DC=company,DC=com"

I need to get rid of just the "CN=username," part (note that i need to
get rid of the " , " also)

I ran across an article that talks about trim() but dont know how that
would work since the usernames will be different every time.

help ?
hmmm off the top, something like:

Dim original = "CN=username,OU=computers,OU=abingdon, OU=MAR,OU=Customers,DC=company,DC=com"
Dim parts() As String = original.Split(",".ToCharArray())
Dim newString = String.Join(",", parts, 1, parts.Length - 1)
Console.WriteLine(newString)

Or

Dim original As String = "CN=username,OU=computers,OU=abingdon, OU=MAR,OU=Customers,DC=company,DC=com"
Dim s As String = original.Substring(original.IndexOf(","c) + 1)
Console.WriteLine(s)

HTH
--
Tom Shelton
Oct 3 '08 #4
Use indexof to find the position of the first quotation mark, and indexof to
find the first comma, then two substring operations to get the part up and
including the quote and everything after the comma.

(I'm assuming username will be different each time)

A regular expression would be the proper way to do it.

"brett" <pl*********@gmail.comwrote in message
news:d9**********************************@m3g2000h sc.googlegroups.com...
Hey all,

I need to trim the first couple of letters from a string and stop a
particular character.

Here is some code for example:

DN = "CN=username,OU=computers,OU=abingdon, OU=MAR,
OU=Customers,DC=company,DC=com"

I need to get rid of just the "CN=username," part (note that i need to
get rid of the " , " also)

I ran across an article that talks about trim() but dont know how that
would work since the usernames will be different every time.

help ?
Oct 4 '08 #5
Thanks Tom!
I ended up incorporating something like your first example into my
program.
Do you know of any good books that i could pickup to help me out with
VB.NET?

Thanks to everyone who replied!

On Oct 3, 4:33*pm, Tom Shelton <tom_shel...@comcastXXXXXXX.netwrote:
On 2008-10-03, brett <planetbr...@gmail.comwrote:
Hey all,
I need to trim the first couple of letters from a string and stop a
particular character.
Here is some code for example:
DN = "CN=username,OU=computers,OU=abingdon, OU=MAR,
OU=Customers,DC=company,DC=com"
I need to get rid of just the "CN=username," part (note that i need to
get rid of the " , " also)
I ran across an article that talks about trim() but dont know how that
would work since the usernames will be different every time.
help ?

hmmm off the top, something like:

Dim original = "CN=username,OU=computers,OU=abingdon, OU=MAR,OU=Customers,DC=company,DC=com"
Dim parts() As String = original.Split(",".ToCharArray())
Dim newString = String.Join(",", parts, 1, parts.Length - 1)
Console.WriteLine(newString)

Or

Dim original As String = "CN=username,OU=computers,OU=abingdon, OU=MAR,OU=Customers,DC=company,DC=com"
Dim s As String = original.Substring(original.IndexOf(","c) + 1)
Console.WriteLine(s)

HTH
--
Tom Shelton
Oct 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
10
by: Esmael | last post by:
Hi to all, /*****************************/ OS-WIn XP SP2 VB6 SP6 /*****************************/ Is their anyone who can help me with this: Source code written on VB6.
3
by: =?Utf-8?B?Rmxhc2hwcm8=?= | last post by:
i have googled this question but cannot find an answer. i'm running windows vista and i'm using Visual Basic Express 2008. i know the build event button SHOULD be in under the compile tag but i...
3
by: Saucer Man | last post by:
Is this only available as part of Visual Studio or can it be purchased separately? -- Thanks!
1
by: =?Utf-8?B?Rmxhbm1hbg==?= | last post by:
I have a tutorial I was working on with Visual Web Developer 2005 express. Very basic stuff intro to asp.net. All was working fine a few days ago. I took my pc home and installed the visual studion...
7
by: andrewb | last post by:
Hi all, Having some trouble using named pipes and Visual Basic .NET and would appreciate and help you could offer. Essentially I am trying to develop a simple client/server application that...
6
by: Miro | last post by:
I can run an exe ( and its install ) i have created on my machine. The exe has a button that populates a dataset and then shoots it to a crystal report. But... Installing the setup.exe on my...
4
by: Miro | last post by:
<i have also added this reply to the other newsgroup - now that I have realizd ( and assuming ) it is not a localized error directly to vb.> I have found this link on the website:...
5
by: CAM | last post by:
Hello, I am using SQL Server Express 2008 for my database and Visual Studios 2008 - Visual Basic.Net for my forms. I Gone into VS 2008 and specify the source of data using the Data Sources...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.