VB.NET-OBJECT REFERENCE

VB.NET-OBJECT REFERENCE

cturlington
Collaborator Collaborator
1,021 Views
5 Replies
Message 1 of 6

VB.NET-OBJECT REFERENCE

cturlington
Collaborator
Collaborator

Hello,

 

I am using Civil 3D 2016.

 

I have been reviewing the Autodesk Training Labs for VB.NET.  Presently working on Lab5.  A common error I get is "Reference to a non-shared member requires an object reference" and "myPalette" is not a member of Lab5.Lab5.lab5.  This is referring to "myPalette" and "Me.myPalette.TreeView1.Nodes".  These two statements have blue squiggly underlines.  I have referenced Lab4 that defines myPalette and assigns it a value, which I always run first before running Lab5, since Lab5 depends on results of Lab4.  However, it is unclear why I would need to create an Object Reference in order to resolve the error I am getting since I have referenced Lab4 already?

0 Likes
Accepted solutions (1)
1,022 Views
5 Replies
Replies (5)
Message 2 of 6

Jeff_M
Consultant
Consultant

@cturlington, I don't have a specific answer to your issue, but an observation that may help....The labs were menat to build on one another in the same project. If you look at the code samples, each lab has the code duplicated from the previous lab, they were meant to be used as you are attempting to do, therefor you are making it much harder on yourself learning things that were not intended to be a part of the labs. I recommend learning the basics that the labs are teaching before trying to learn how to use objects from other projects within the same solution.

 

As for continuing on as you are, if you so choose, you should post the code you have for your lab 5 so we can see what/how you are attempting to access the objects from Lab4.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 6

cturlington
Collaborator
Collaborator

Jeff,

 

Thanks for your feedback.  I was assuming my effort was a little more than what the labs require due to having the lessons separated.  However, this will help me understand how to work with the VB reference concepts.  If you do not mind, I have attached a copy of my Lab5 for your review.  Any feedback or suggestions would be greatly appreciated. 

0 Likes
Message 4 of 6

Jeff_M
Consultant
Consultant
That is just the project properties & build info. Post the Lab5.vb file in order to see what you are doing code-wise.
Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 5 of 6

cturlington
Collaborator
Collaborator

Jeff,

 

Attached is "myCommands.vb"  I did not have a LAB5.vb but only myCommands.vb.  Let me know if htere is more I should submit.

0 Likes
Message 6 of 6

Jeff_M
Consultant
Consultant
Accepted solution

Ha! I surprised myself....I don't code in VB so it was a shot in the dark whether I'd get this or not. But with the following changes it appears to now work:

 

In the Lab4 code you need to make 3 changes:

Public Shared myPaletteSet As PaletteSet

Public Shared myPalette As UserControl1

 

And the Treeview control's Modifiers property needs to be changed to Public.

 

Then in the Lab5 myCommands.vb, change the Imports statements like so:

'Imports System.Windows.Controls '<<<not sure why this was here??
Imports Lab4.adskClass '.myPalette.myPalette
'Imports LAB4.UserControl1 ''just import the class, not the objects inside of it.

 

This allows the code to compile, load, and run. Although nothing gets shown in the Palette becasue the Treeview was never previously filled with anything (based on the code I have to test with).

Jeff_M, also a frequent Swamper
EESignature