I found this piece of code on the forum that apparently worked for someone. But it's confusing to me.
I want to pass a string from say Form1 to Form2.
Another option is to create a Class and store the variable there. I have done that for an application I created and it works well. For example:
Public Class Global (whatever you want to call it)
Private Shared EmpID as String
Public Shared Property EmpIDVal as String
Set(ByVal Value As String)
EmpID = Value
To use in a form, send the value to this class by saying global.EmpIDVal = txtEmpID.Text.
In order to get the value in a form, use the following code:
Public Function ID() As String
Hope this helps :-)
The generated code from my Form2 looks like this:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Are you able to use the 'Dim frm AS New Form2(text_value)' and modify the Form2_Load() above to accept this
text_value. Or do you have to balloon across the Atlantic to do this....using code similar to the code I pasted
at the top. This is a function that will be necessary for me in about (20) forms. If it means setting up a Class
or something else that can be used globally..I'm all for it. Just the same I've never created a separate Class
nor do I know where it would go.
My Module1.vb contains public variables as follows:
Public this and that
If it can be added here...where do I add it.
Otherwise where and how would I add a Class to be used globally through the application and then how
would I suscessfully use it?
Thanks in advance!