Share this post

Link to post

Share on other sites

in VB .Net, there are two sorts of methods - shared and not sharedShared methods can be accessed through the type where they were defined, non shared require that you call them through a variable of that type (that holds and actual instance)

VB actually worked this way too, but it automatically defined default variables with the same name as Forms in your application - VB .Net will do this with the 2005 edition, but doesn't on 2002 or 2003.

What you need to do is have a variable that holds a form1 instance accessible from the code you want to call the method from - you can for example have a variable of type Form1 in a module, and on Form1's load event assign "Me" to that variable - you can then go and call non shared members through that variable:

Module Module1 Public Shared Var1 as Form1End Module

'...'on form1's load event:Var1 = Me

'...'On your code:Var1.Show()

0

Share this post

Link to post

Share on other sites

Im creating a game for a school project due tommorow. It is a basic matching game where you flip over two tiles at a time to see if they match. to do this i set up a class holding the button object and some information about the tile and its click event. in the click event i need to acess some variables defined outside the class and a sub that will refresh the a couple labels on the form displaying the score and so forth. I need a simple way to be able to increase the score and call the refresh sub from the click event in this class.