|
-
July 25th, 2005, 03:41 PM
#1
Passing data between forms...
Ok, I have 2 forms. Form1 creates Form2. My question is, how can I pass information between the two of them? For example, if I had a DB connection object that needed to be passed from one to the other, how can I pass that object? Or any other object for that matter...
Code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim new_form As New Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
new_form.Show()
End Sub
End Class
Code:
Public Class Form2
Inherits System.Windows.Forms.Form
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
End Sub
End Class
-
July 25th, 2005, 05:02 PM
#2
Re: Passing data between forms...
What I did to share data between forms is have a module and declare the variables int eh module as friend. Youc an read and wrtie tot his variable
e.g.
Option Explicit On
Option Strict On
Module GlobalData
Friend g_CReg As New CReg
End Module
now this variable g_Creg is accesible throughouyt the app.
Mayeb this will solve your problem.
-
July 25th, 2005, 07:07 PM
#3
Re: Passing data between forms...
 Originally Posted by venAdder
What I did to share data between forms is have a module and declare the variables int eh module as friend. Youc an read and wrtie tot his variable
e.g.
Option Explicit On
Option Strict On
Module GlobalData
Friend g_CReg As New CReg
End Module
now this variable g_Creg is accesible throughouyt the app.
Mayeb this will solve your problem.
That actually went quite a bit in the way to solving my problem.
By doing the below, will I get a thread-safe module?
Code:
<System.Runtime.Remoting.Contexts.Synchronization()> Module pass_around
Public int As Integer = 0
End Module
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|