Form Accessability through an added Module

Shaddow

Member
Joined
Jan 6, 2004
Messages
14
Im missing something between the jump from an earlier version of VB.

I use to be able to do something like this: (say I have 2 modules and 1 form, form1, and main as modules and form1 as a form.

something like this use to work.

(inside the main module)

Form1.(whatever sub or funciton is)

in the new VS in the VB.net stuff Im not able to do this.

I get something like .

(inside main module)
Form1.(small list with like ActiveForm) but none of my public functions from form1(the module)

I think this is a brain cramp that Im missing something very obvious.

Thanks.:mad: :mad:
 
In VB.Net forms are just classes - you will need to create a valid instance of the form before you can use it.
Code:
dim f as new Form1
f.Show()
 
the form is the primary start object. and is already instantiated.
something like this. the form opens and on a button of the form I have a button. it calls a function from the added module (which then takes control and goes from there. What I want is a way, once in that added module to access form functions, methods and properties. all I get available is a small list that starts with something like form1.ActiveForm.something etc. there are no references to any functions even though I made them public. or am I just missing something....
 
Modules are not the best way to go in VB.NET, classes with shared members are more fit in the .NET world.
Pass the forms instance to the modules method that will do what you want.
Code:
in your module
Public Sub DoSomthing(byval f as FormType)
do something
End Sub
Then when you call the method from your form, do this:
Code:
DoSomething(me)
Then you will be able to access the instance you passed.
 

Similar threads

Back
Top