[RESOLVED] Passing info between instances of forms
What's the best way to pass info between instances of forms in VB.NET?
If I remember right, in 6.0 you could just declare a global variable, but they seem to have gotten rid of that in .NET.
This is in a program to read and write to a database. When I'm reading records in the program, I made the option to "EDIT" the record. Right now, that button brings up a new form on which to make the edits. I'm trying to figure out a way to give the record index and the primary key of the record to the EDIT form from the READ form so I can edit the right entry. How can I pass those two integers to the edit form when I initialize it (or soonthereafter).
Any help is appreciated, thanks!
Re: Passing info between instances of forms
Add a module to your project and declare public variables.
VB Code:
Module Module1
Public _Test As String
End Module
Both forms in your project can set/read the value in _Test.
Re: Passing info between instances of forms
Perfect! That exactly what I was looking for. I was on the right track, because I did try creating a class to hold variables, but I was using subroutines to get and set the variables, and it wanted me to instantiate the class to use them. Thanks a bunch!