Prev: Split Method
Next: How to check a AD user's password
From: ekkehard.horner on 23 Mar 2010 14:18 Tom Lavedas schrieb: > On Mar 23, 12:54 pm, Dan <D...(a)discussions.microsoft.com> wrote: >> Hey Al, >> Yes, the value would be "one,two,three" or something like that and I'd >> like the default value of the new input box to be just "two,three". >> Thanks! >> > > I use something like this to remove the first item in a comma > delimited list ... > > sText = "one,two,three" ' for example > aItems = Split(sText, ",") > aItems(0) = "" > sText = Mid(Join(aItems, ","), 2) ' less the first item > _____________________ > Tom Lavedas Or: >> sText = "one,two,three" >> WScript.Echo Join( Split( Split( sText, ",", 2 )( 1 ), "," ), "-" ) >> WScript.Echo Join( Split( Mid( sText, 1 + InStr( sText, "," ) ), "," ), "*" ) >> two-three two*three >>
From: Tom Lavedas on 23 Mar 2010 14:57 On Mar 23, 2:18 pm, "ekkehard.horner" <ekkehard.hor...(a)arcor.de> wrote: > Tom Lavedas schrieb: > > > > > On Mar 23, 12:54 pm, Dan <D...(a)discussions.microsoft.com> wrote: > >> Hey Al, > >> Yes, the value would be "one,two,three" or something like that and I'd > >> like the default value of the new input box to be just "two,three". > >> Thanks! > > > I use something like this to remove the first item in a comma > > delimited list ... > > > sText = "one,two,three" ' for example > > aItems = Split(sText, ",") > > aItems(0) = "" > > sText = Mid(Join(aItems, ","), 2) ' less the first item > > _____________________ > > Tom Lavedas > > Or: > > >> sText = "one,two,three" > >> WScript.Echo Join( Split( Split( sText, ",", 2 )( 1 ), "," ), "-" ) > >> WScript.Echo Join( Split( Mid( sText, 1 + InStr( sText, "," ) ), "," ), "*" ) > >> > two-three > two*three > >> The first one is excellent. Why didn't I think of that? ;-) _____________________ Tom Lavedas
From: Dan on 23 Mar 2010 15:22 Stating the obvious.... Richard = Rockstar! Worked like a charm! "Richard Mueller [MVP]" wrote: > > "Dan" <Dan(a)discussions.microsoft.com> wrote in message > news:86D2C999-46FC-49ED-8DCE-BC34746436FA(a)microsoft.com... > > Hey all, > > I'm trying to get split to get all the parameters minus one (the first > > one). For example: > > > > I get all the parameters needed with this: > > > > NewGroup = Split(OldGroup,",", -1) > > > > Then I create an Input box and try to get all of the members of the new > > array (minus the first one) like this: > > > > objOU=InputBox("Enter the DN of the OU:", "Select OU", groupname2(1 & 2 & > > 3)) > > > > Now, I know this has several issues. First and foremost it doesn't work > > and > > second I don't know how many other elements I'm going to have. Is there a > > way to loop through the remaining items to get them all in the new input > > box? > > > > Thanks for any help! > > You would need to loop through the array. The first element would have index > 0, which is the element you want to skip. The UBound function would return > the maximum index. For example: > ======= > NewGroup = Split(oldGroup, ",") > GroupNames = "" > For k = 1 To UBound(NewGroup) > If GroupNames "") Then > GroupNames = NewGroup(k) > Else > GroupNames = GroupNames & "," & NewGroup(k) > End If > Next > > objOU=InputBox("Enter the DN of the OU:", "Select OU", GroupNames) > ========= > However, I'm guessing that the value of oldGroup is the Distinguished Name > (DN) of an object, and you want the DN of it's parent container/OU. If so, > the code above will fail if the Relative Distinguished Name of the object > (the Common Name if the object is a user or group or computer) has an > embedded comma. For example, the DN could be: > > cn=Smith, James,ou=West,dc=MyDomain,dc=com > > There are ways to reliably parse this, but the best method is to bind to the > object and use the Parent method to retrieve the ADsPath of the parent > container or OU. The ADsPath will be the DN with the string "LDAP://" > prepended. For example: > > ' Assuming the value of oldGroup is the DN of a group object. > ' Bind to the object. > Set objGroup = GetObject("LDAP://" & oldGroup) > ' Retrieve ADsPath of parent OU. > strParentADsPath = objGroup.Parent > ' Remove LDAP:// moniker to get DN of parent OU. > strParentDN = Mid(strParentADsPath, 8) > > strOU = InputBox("Enter the DN of the OU:", "Select OU", strParentDN) > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > > . >
From: ekkehard.horner on 23 Mar 2010 16:01
Tom Lavedas schrieb: > On Mar 23, 2:18 pm, "ekkehard.horner" <ekkehard.hor...(a)arcor.de> > wrote: >> Tom Lavedas schrieb: >> >> >> >>> On Mar 23, 12:54 pm, Dan <D...(a)discussions.microsoft.com> wrote: >>>> Hey Al, >>>> Yes, the value would be "one,two,three" or something like that and I'd >>>> like the default value of the new input box to be just "two,three". >>>> Thanks! >>> I use something like this to remove the first item in a comma >>> delimited list ... >>> sText = "one,two,three" ' for example >>> aItems = Split(sText, ",") >>> aItems(0) = "" >>> sText = Mid(Join(aItems, ","), 2) ' less the first item [...] >> Or: >> >> >> sText = "one,two,three" >> >> WScript.Echo Join( Split( Split( sText, ",", 2 )( 1 ), "," ), "-" ) >> >> WScript.Echo Join( Split( Mid( sText, 1 + InStr( sText, "," ) ), "," ), "*" ) >> >> >> two-three >> two*three >> >> > > The first one is excellent. Why didn't I think of that? ;-) [...] (a) because you did not have a working solution to start with (like me)? (b) because your instinct told you not to waste resources (two splits, two arrays)? (that's why I like the second one better) |