non-shared member of a class
(Tuesday, December 21, 2004)
Found the following interesting discussion in the Newsgroups:
non-shared member of a class by:Mike Johnson
| I got the error below, can someone provide the answer in code to the problem listed below. Thanks.
You have tried to reference a non-shared member of a class from within a shared method or shared method initialize. The following code provides an example of such a situation:
Class Sample Public x as Integer 'An instance member Public Shared Sub Bar() x = 10 'Produces the error End Sub End ClassThe shared method does not actually operate on any one instance of the class. Instead, each instance has its own copy of x, which causes the error.
To correct this error
a.. Provide an explicit instance of the class whose member you wish to reference. In the example above, provide an explicit instance of the class containing the copy of x which you wish to set equal to 10. I can't use shared to fix the problem so please explain in code how to do the above. Thanks
| | | Reply: by:Anonymous
| | | It's kind of funny, when you think about it.
You started your post with the ruse that this was an error you encountered while writing code. You then posted a question verbatim out of a text book.
What's worse, the question has already been answered in your own post. Simply follow the instructions under the line "To correct this error".
|
|
1 Comments:
Well actually it's a bit obvious that he doesn't know the code to do it. Thats what he is asking for twat
Post a Comment