Referencing a specific instance of a class... 
Author Message
 Referencing a specific instance of a class...

Hi,

I am fairly new to oo programming and keep stumbling across this problem.
When I have multiple instances of a class, how do I reference each one
individually.

One example is trying to change the value of a text box on a form when a
property is changed (externally). eg:

Public Shared sTheText As String
Public Shared Property TheText() As String
    Get
        Return sTheText
    End Get
    Set(ByVal Value As String)
        sTheText = Value
        Textbox1.Text = sTheText
    End Set
End Property

This returns the message: 'Cannot refer to an instance member of a class
from within a shared method or shared member initializer without an explicit
instance of a class'. I understand why I can't do this....but can't work out
how I should be doing it.

Thanks in advance.

Stu



Fri, 04 Nov 2005 21:54:06 GMT  
 Referencing a specific instance of a class...

Quote:
> I am fairly new to oo programming and keep stumbling across this
> problem. When I have multiple instances of a class, how do I
> reference each one individually.

> One example is trying to change the value of a text box on a form
> when a property is changed (externally). eg:

> Public Shared sTheText As String
> Public Shared Property TheText() As String
>     Get
>         Return sTheText
>     End Get
>     Set(ByVal Value As String)
>         sTheText = Value
>         Textbox1.Text = sTheText
>     End Set
> End Property

> This returns the message: 'Cannot refer to an instance member of a
> class from within a shared method or shared member initializer
> without an explicit instance of a class'. I understand why I can't do
> this....but can't work out how I should be doing it.

The Textbox on which Form is to be changed? There might be no, one or
several instances of the Form.

--
Armin



Fri, 04 Nov 2005 22:04:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Constructing Class Instances from Specific Objects Only

2. Reference to instance of a class

3. newbie: private class variables are visible in class instances

4. Find out if somebody make an instance of a Class without having access to the Class

5. nested class inherits containing class accessing private instance members

6. instance a class from its class name

7. Pass Class reference of unkown class

8. Class of control was not a loaded control class - Reference Replaced with unknown .OCA file

9. referencing classes in other classes

10. Set / Get/CreateObject and specific process or instance

11. Find multiple instances of a specific word and change the color

12. Using GetObject to open file in a specific instance of Excel

 

 
Powered by phpBB® Forum Software