我正在使用Login_Form
开发Visual Basic。我想将值从Login_Form
传递到TableSelection
。它第一次起作用,但是当我注销并再次登录时。 TableSelection
的值与我第一次通过时相同。
这是我的代码:
idNumber
是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
登录名可以使用不同的EmployeeID,但TableSelection不会更新ID
答案 0 :(得分:1)
一种方法是将整数从Form1传递到Form2中,如下所示:
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