Visual Basic 2008 - Trim ?

  • Thread starter Thread starter brett
  • Start date Start date
B

brett

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 ?
 
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,", "")
 
brett said:
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.
 
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.
 
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!
 
Back
Top