sethindeed Posted February 25, 2003 Posted February 25, 2003 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 ? Quote What I don't know keeps me excited...
sethindeed Posted February 25, 2003 Author Posted February 25, 2003 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 ! :) Quote What I don't know keeps me excited...
bpayne111 Posted March 1, 2003 Posted March 1, 2003 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 Quote i'm not lazy i'm just resting before i get tired.
*Gurus* divil Posted March 1, 2003 *Gurus* Posted March 1, 2003 A Form object will be passed by reference no matter how you declare the parameter. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
UCM Posted March 3, 2003 Posted March 3, 2003 (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 March 3, 2003 by UCM Quote UCM >-)
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.