Hi. I've spent a lot of time searching on google on how to do what I describe below but I have not had any luck. I am using Visual Studio Express 2012, and I am very new to vb.net and only have programming experience from a couple of college classes. I have successfully been getting variables from my forms, but I don't know how to do what I describe below. I feel like there is a good chance that I am going about it the wrong way, and I need to do it some other way. Thank you ahead of time for any input.
Lets say I have two forms, Form1 and Form2
Each form has a text box called TextBox1
When the enter button is hit Form1 the following happens:
A public variable FormSelected gets a value of "Form1"
Sub Main1 is called
When the enter button is hit on Form2 the following happens:
A public variable FormSelected gets a value of "Form2"
Sub Main1 is called
Once Sub main an if statement is ran to see what form was used
If FormSelected = "Form1" Then
Else
End If
In the If statement I want to be able to make a variable the same as the form selected so my entire program can run off that varialbe when getting the value from TextBox1
Here is how I can get the variables from Form1
Dim Variable1 as String
Variable1 = Form1.TextBox1.Text
Here is how I can get the variables from Form2
Dim Variable1 as String
Variable1 = Form2.TextBox1.Text
I want to be able to do something like
Dim FormName as Object (I don't know what it would be set too?)
If FormSelected = "Form1" Then
FormName = Form1
Else
FormName = Form2
End If
To get the variable from either form now I want something like this
Dim Variable1 as String
Variable1 = FormName.TextBox1.Text
Thanks!
Lets say I have two forms, Form1 and Form2
Each form has a text box called TextBox1
When the enter button is hit Form1 the following happens:
A public variable FormSelected gets a value of "Form1"
Sub Main1 is called
When the enter button is hit on Form2 the following happens:
A public variable FormSelected gets a value of "Form2"
Sub Main1 is called
Once Sub main an if statement is ran to see what form was used
If FormSelected = "Form1" Then
Else
End If
In the If statement I want to be able to make a variable the same as the form selected so my entire program can run off that varialbe when getting the value from TextBox1
Here is how I can get the variables from Form1
Dim Variable1 as String
Variable1 = Form1.TextBox1.Text
Here is how I can get the variables from Form2
Dim Variable1 as String
Variable1 = Form2.TextBox1.Text
I want to be able to do something like
Dim FormName as Object (I don't know what it would be set too?)
If FormSelected = "Form1" Then
FormName = Form1
Else
FormName = Form2
End If
To get the variable from either form now I want something like this
Dim Variable1 as String
Variable1 = FormName.TextBox1.Text
Thanks!