Doggo120 Posted October 18, 2011 Posted October 18, 2011 (edited) 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: 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! Edited October 18, 2011 by Doggo120 Quote
Administrators PlausiblyDamp Posted October 18, 2011 Administrators Posted October 18, 2011 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.