absent Posted April 27, 2004 Posted April 27, 2004 :confused: I have a small question relating to the old problem of passing variables between forms in vb.net. I think I might have found a way to do it but would like to know if it will work and if not why? Before the class declarations ie above the line Public Class Form2 Inherits System.Windows.Forms.Form If I insert 'Inserting this line Imports Project1.Form2 Public Class Form2 Inherits System.Windows.Forms.Form Will it not have the same effect as declaring the form "class" as an accesable object? By doing so I should be able to call the values from the different controls? Please bare in mind this is VB.net and not C#. Any feedback will be greatly appreciative... Quote P.L.U.R - Peace, Love, Unity, Respect :P
akiaz Posted April 27, 2004 Posted April 27, 2004 I thought the Imports statement imports a namespace. Your line is specifying a class to import and that doesn't make sense. If both of these forms are in the same project, then they are probably already in the same namespace. Otherwise, just import the namespace if they are different. But a form is an instantiable object which means you have to define an instance of the form to get at it's properties and methods. Quote
absent Posted April 27, 2004 Author Posted April 27, 2004 erk... hmmmmmmmmmmmmmm there is that point also... I'm sort of still getting used to the more basic principles of VB.net - But know a bit moer on the advanced ones - Having been thrown in the deep end was both a good and bad thing... Cheers for the help m8 Quote P.L.U.R - Peace, Love, Unity, Respect :P
wessamzeidan Posted April 27, 2004 Posted April 27, 2004 It will have no effect since you need to create an object of type form2 to access its public members and methods Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
AlexCode Posted April 27, 2004 Posted April 27, 2004 Hi... I think you're confuding things a bit... or maybe it's just me... Lets see... The Imports expression doesn't declare objects. You still have to declare a new instance of the object so you can actually work with it so... what's the point? You started the post with: ...old problem of passing variables between forms in vb.net... Why do you call it a problem? there's plenty of ways of doing it... just choose the best for you... I enumerate a few ones: 1- Just pass the variables in the New parametters, ByVal or ByRef as you need. 2- Declare those vars in a module or as Shared. 3- Create a new EventArgs inherited class with your new properties and pass it in the 'e' parametter. I think those 3 ways would fill your needs... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Administrators PlausiblyDamp Posted April 27, 2004 Administrators Posted April 27, 2004 http://www.xtremedotnettalk.com/showthread.php?goto=newpost&t=83092 may be of some use Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.