|
-
Jul 7th, 2011, 09:51 AM
#1
Thread Starter
New Member
[RESOLVED] A Public object is not accessible from another class.
I'll try to explain this the simplest way I can, and I'll be happy to provide more elaboration as needed.
I've created a class, class playership, as part of a little strategy game for my own practice.
I've created the instance of a playership object in my main form using the following code:
Code:
Public Class Form1
Public mainship As New playership
End Class
I need to access this object from another windows form, a dialog box to be exact, to set its properties.
However, when I attempt to set the properties of the object in the dialog box's code, as such:
Code:
Public Class dialog1
Sub whatever() 'Stats are set within an event in the code
mainship.setstats(attacktoset, defensetoset)
End Sub
End Class
I'm told that: "mainship is not declared. It may be inaccessible due to its protection level."
I'm a little confused about this because I thought a public object or variable could be accessed from anywhere within a project. So, my question is, what can I do to make this object accessible from anywhere in my project?
If you need more elaboration, please let me know. I greatly appreciate the help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|