Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

: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...

P.L.U.R - Peace, Love, Unity, Respect :P
Posted

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.

Posted

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

P.L.U.R - Peace, Love, Unity, Respect :P
Posted

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

Software bugs are impossible to detect by anybody except the end user.

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...