Solved

Reference to a non-shared member in VB.NET

Posted on 2011-03-04
3
367 Views
Last Modified: 2012-05-11
Hello Experts:

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

Accepted Solution

by:
lenordiste earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to save a picture box in a specific network folder using vb.net 2013 7 26
Syntax Error 2 42
Angular JS Route 3 45
Get Top Visible Row of Datagridview 6 26
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now