12-22-2011 09:08 AM
End Function
Solved! Go to Solution.
12-22-2011 11:36 AM
This seems to work (at least, it produces a result and doesn't return an error). There might be a bug in your VisualBasic code - there's a "Return" statement in the middle of your For Each loop. As a result, I think that it returns only the first item found (in which case there's no need for the For Each loop at all). The attached LabVIEW code returns the entire array, although at least on my machine that's only a single element. VI snippet is in LabVIEW 2009, but the attached VI is saved for 8.6 (hope that works with the .NET components) since you mentioned that that's what you're using.
12-23-2011 03:53 AM
natahan, You rock! Quick and Good!
Your code produces results that seem to be reasonable on my machine and I'll have to check them on other PCs.
Now I wonder where did you get that inspiration from to use the "GetEnumerator"- and than "MoveNext"-, "Current"-nodes? Is there any reading out there you can suggest, or is that your experience after years of trial-and-error? I'm not a LV newbie and would like to save me the embarrassment of asking you again with the next .Net problem.
Of course I'd also like to know if "great" MSDN is providing us somewhere with a list of their Enums?
The above VB code by the way I found at http://www.vbdotnetforums.com/security-obfuscation/15338-computer-id.html and some more query pairs at http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/08bb5fdc-7f00-4fd6-908c-f6465e734a39/
Thanks for the LV8.6 code; it works.
Jannis
12-24-2011 12:13 AM
I know from experience that any time there's a For Each loop, you'll be iterating through a collection. I started poking through the available methods and properties and found "GetEnumerator" which looked promising. I ran a search for GetEnumerator and the first result returned was http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.getenumerator.aspx which explains how to use MoveNext and Current to get each element of the collection in sequence.
12-24-2011 03:31 AM - edited 12-24-2011 03:33 AM
@Jannis wrote:
Now I wonder where did you get that inspiration from to use the "GetEnumerator"- and than "MoveNext"-, "Current"-nodes? Is there any reading out there you can suggest, or is that your experience after years of trial-and-error? I'm not a LV newbie and would like to save me the embarrassment of asking you again with the next .Net problem.
This is common programming knowledge :-). Honestly it helps to have some experience in both the .Net language and also the actual flavor your example code is in. Although here Visual Basic and C# are reasonably close to each other to work either. The For each (foreach in C#) keyword in the .Net language is simply an invocation for an iterator, and the logical implementation of iterators in .Net is the object enumeration. Java has a similar construct where you use "for (ObjectType obj : objectCollection)".
12-24-2011 04:08 AM
12-24-2011 07:19 PM
Is this the list you want? http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084%28v=VS.85%29.aspx
12-25-2011 05:00 AM
Great! Exactly what I wanted and couldn't find! Guess I'll be sitting down now and improve my "common programming knowledge".
Thanks nathand and merry X-mas
Jannis