Reputation: 49
I am working on Visual Basic with a Login_Form
. I would like to pass a value from Login_Form
to TableSelection
. It works for the first time, but when I log out and login again. The TableSelection
get the same value as the first time I passed.
Here's my code:
idNumber
is the public variable in the TableSelection
Private Sub LoginButton_Click(sender As Object, e As EventArgs) Handles LoginButton.Click
Select Case EmployeeIDTextBox.Text.Substring(0, 1)
Case 1
MainScreen.Show()
'Number starts with 2 takes user to waiter screen
Case 2
TableSelection.idNumber = EmployeeIDTextBox.Text.Substring(1, 1)
TableSelection.Show()
End Select
Me.Hide()
End Sub
The login works with different EmployeeID, but the TableSelection does not update the ID
Upvotes: 0
Views: 91
Reputation: 827
One way to do this is to pass the integer into Form2 from Form1 as shown below:
Public Class Form1
Dim IntFromForm1 As Integer = 2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Using Form2 As New Form2(IntFromForm1)
Form2.ShowDialog()
End Using
End Sub
End Class
Public Class Form2
Dim MyForm2Int As Integer
Public Sub New(ByVal MyIntFromForm1 As Integer)
InitializeComponent()
MyForm2Int = MyIntFromForm1
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MsgBox(MyForm2Int)
End Sub
End Class
Upvotes: 1