|
-
Mar 5th, 2004, 08:51 PM
#1
Thread Starter
Frenzied Member
Control Instance Error [Resolved]
For some reason, when i use the following line of code
VB Code:
Dim SelectedComputers() as String
...
clstAddresses.CheckedItems.CopyTo(SelectedComputers, 0)
I get an error saying that the Object reference is not set to an instance of an object. Now the most confusing part about it is that i have other code that is used before it that works fine
VB Code:
If clstAddresses.CheckedItems.Count = 0 Then
I have another prog that uses code like the first code sample that works fine but that one doesn't. The only thing i can think of is that it must have something to do with the inherited forms feature, but the control is local to that form and anything else but the copyto thing seems to work fine. Any Ideas?
Last edited by Ideas Man; Mar 5th, 2004 at 09:40 PM.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Mar 5th, 2004, 09:14 PM
#2
CopyTo copies a collection or array to another array. The destination array must already be initialized with enough elements to fit the Copied items.
VB Code:
Dim SelectedComputers(clstAddresses.CheckedItems.Count-1) as String
clstAddresses.CheckedItems.CopyTo(SelectedComputers, 0)
-
Mar 5th, 2004, 09:39 PM
#3
Thread Starter
Frenzied Member
Thanks Edneeis that's what was wrong. After looking at my other code again, I noticed that line, lol, must be tired.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|