Reference to a non-shared member in VB.NET

Posted on 2011-03-04
Medium Priority
Last Modified: 2012-05-11
Hello Experts:

What does this error want me to do to eliminate it?
Question by:gbmcneil
  • 2
LVL 11

Accepted Solution

lenordiste earned 500 total points
ID: 35041218
you are trying to access a function without instantiating your object.
so for instance you have a class "Test" containing a method "DoSomething" and in your code you are doing:

instead of instantiating your object first:
dim t as new Test()

what you can also do is simply put the keyword "shared" in front of your method definition if that makes sense for your class design.

if you want the MS exact explanation:

Author Comment

ID: 35041591
Hello lenordiste -

Thanks very much for responding. You've hit the nail on the head. This is exactly my situation.

Could I ask you one more question?  If the assembly were a COM DLLand not an executable, how would I get access to the DoSomething function in Class Test from outside the DLL?
Would I instantiate...

Dim t as New dllname.Test()


Author Closing Comment

ID: 35041596
Your answer was a big help.

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article describes and provides a custom-made tool I wrote to give businesses a means of identifying commercial music content, without having to expend too much effort. Business recordings are easily identified from possibly illegal music files …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question