?
Solved

Reference to a non-shared member in VB.NET

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

What does this error want me to do to eliminate it?
0
Comment
Question by:gbmcneil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
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:
Test.DoSomething()

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

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:
http://msdn.microsoft.com/en-us/library/zwwhc0d0(VS.80).aspx
0
 

Author Comment

by:gbmcneil
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()
t.DoSomething()

Thanks.
0
 

Author Closing Comment

by:gbmcneil
ID: 35041596
Your answer was a big help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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 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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

771 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