Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to access some form controls from one of the class I created.

 

I tried to declare a temp variable as Form1 but when the program reach the following instruction :

 

Me.Text = tmpForm1.Listbox1.SelectedItem

 

I am getting an error that told me that my object is not instanced...

Any ideas ?

What I don't know keeps me excited...
Posted

As reference :

 

If you declare the variable used to contain your form in a module, you will be able to use your form components from a separate class.

Thanx god ! :)

What I don't know keeps me excited...
Posted

you could pass the form as a parameter to the class

if you plan on changing these values use ByRef instead of ByVal for your form parameter

 

just a suggestion

i'm not lazy i'm just resting before i get tired.
Posted (edited)

try setting your created class as the startup class and create a new instance of each form you wish to use in the code of your created class with:

 

public myForm1 as New form1

 

and then reference that variable in form1's code with the namespace of your project such as:

 

myProject1.myClass1.myForm1.blahblahblah

 

I used a module class to achieve this, see This Thread and scroll to the very end to get the latest working copy after all of the slight modifications...

Edited by UCM

UCM

>-)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...