Accesing Class Methods

Doggo120

Newcomer
Joined
Oct 7, 2011
Messages
23
Location
Colombia
Accesing Another Class Methods

Yooo, Super-askingdude here!

Is there a way to access Class methods and variables without using the Shared statement or the New statement? Here's my code:

Code:
Public Class BigClassy
    Public vPublicVariable As Integer

    Public MyStructy As Structy     ' I'm not sure if I have to use NEW here
End Class

Public Structure Structy
    ' Creating something like "Public BC as new BigClassy" here will do?
    Public Sub FindBigClassyVariable()
        BigClassy.vPublicVariable = 100     ' This returns an error of course
    End Sub
End Structure

Do I have to create a new instance of BigClassy within Structy to access the current value of vPublicVariable? (because I assume that doing so will erase it)

This is like melting my brain... I don't know how to achieve my goal here.
Well, I hope someone will help me!
Love!
 
Last edited:
Re: Accesing Another Class Methods

If you are creating a class member without the shared keyword then that member is associated with an instance of a class - this means you would need to declare a variable and assign an instance of the class to this variable and access the member via this variable.

If it is marked as shared then it is associated with the class rather than an instance and only one copy would ever exist in memory - this is accessed via the class as opposed to an instance.

In practice though you would normally be looking at instances rather than shared members unless you have a good reason to use shared. It might help if you gave a little more detail about what you are trying to do and see if anyone can give you more specific advice.
 
Back
Top