Results 1 to 5 of 5

Thread: Accessing a classes attributes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    26

    Accessing a classes attributes

    I have a class with attributes I want other classes to access(clsAll) through property methods. I have 3 other classes(forms) that I want to access the attributes that have been instantiated and given values in clsAll by the first form class. The problem is that the second form class can only access attributes of clsAll by instantiating it again thereby initialising the attributes again and losing the values they already contain.

    Help!!!!!!!!!


    Thanks

    erimus
    erimus

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    When you say attributes do you really mean properties?

    Or do you mean attrbutes like DefaultEvent, Serializable...?

    You need to access the same instance of the class. The best way is to pass it between the forms or make a module level variable that holds it.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    26

    Re: Accessing a classes attributes

    Thanks Edneeis for the reply. What I mean by attributes are the values that can be returned by a property get method. I need guidance on how I can access the same instance of clsAll from another class without having to instantiate it again.

    Thanks
    erimus

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You can either declare it in a module, or pass it to the form that needs it. This is actually a pretty common question. You might want to try searching for, access a control on another form, or something like that, because you would do this the same way.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    26

    Re: Accessing a classes attributes

    Thanks Edneeis. I thought of passing attributes to another form as suggested but this did not look to OO to me. So it occurred to me that overriding the New() method with New(arg1, arg 2, arg3) where arg(n) is the attributes I want passed to another form. This worked a treat, and I am very greatful to you for pointing me in this direction.
    erimus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width