Results 1 to 3 of 3

Thread: [RESOLVED] Passing info between instances of forms

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    28

    [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!
    Last edited by Sgt Spike; Sep 21st, 2006 at 01:15 PM.

  2. #2
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Re: Passing info between instances of forms

    Add a module to your project and declare public variables.
    VB Code:
    1. Module Module1
    2.     Public _Test As String
    3. End Module

    Both forms in your project can set/read the value in _Test.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    28

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width