|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Returning an array from a function?Private Function ADSIReturnComputers(ByVal BldgMnemonic As String) As ArrayList Dim x As New ArrayList Using oDirectoryEntry As DirectoryEntry = New DirectoryEntry("LDAP://us.ups.com") Using oDirectorySearcher As DirectorySearcher = New DirectorySearcher(oDirectoryEntry) oDirectorySearcher.Filter = "(&(ObjectClass=Computer)(cn=" & BldgMnemonic & "*))" For Each oResult As SearchResult In oDirectorySearcher.FindAll x.Add(oResult.GetDirectoryEntry.Name) Next End Using End Using Return x End Function Is there an easy way to return just a static array of string? Or would that be more work than it's worth? *** Sent via Developersdex http://www.developersdex.com *** Terry,
Your question can be confusing, do you mean return a "static" arraylist as it is in the context of Visual Basis inside a method? Than you should pass that in my idea that arraylist just byval to the method. Cor Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> schreef in bericht news:eYvpPuxyGHA.4844@TK2MSFTNGP04.phx.gbl... > I'm currently using the following function to return an ArrayList: > > Private Function ADSIReturnComputers(ByVal BldgMnemonic As String) As > ArrayList > Dim x As New ArrayList > > Using oDirectoryEntry As DirectoryEntry = New > DirectoryEntry("LDAP://us.ups.com") > Using oDirectorySearcher As DirectorySearcher = New > DirectorySearcher(oDirectoryEntry) > > oDirectorySearcher.Filter = > "(&(ObjectClass=Computer)(cn=" & BldgMnemonic & "*))" > > For Each oResult As SearchResult In > oDirectorySearcher.FindAll > x.Add(oResult.GetDirectoryEntry.Name) > Next > > End Using > End Using > > Return x > End Function > > Is there an easy way to return just a static array of string? Or would > that be more work than it's worth? > > > *** Sent via Developersdex http://www.developersdex.com *** >Is there an easy way to return just a static array of string? Or would Return CType(x.ToArray(GetType(String)), String())>that be more work than it's worth? Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. > Return CType(x.ToArray(GetType(String)), String()) Or more simply,Dim x As New List(Of String) .... Return x.ToArray() -h-
Unicode conversion
Net.WebRequest - Close Connection Resource and Time consuming stuff vfp oledbcommand [Fail] How do I add a c++ library to my vb.net project? Virtual desktop makes .NET modal dialog panels disappear looking for tree/outline control that allows in-place editing AND will expand as I type Visual Studio beginner questions MAking a bound form from a query GDI Handle leak when adding a simple Textbox |
|||||||||||||||||||||||