01.
Public
Class
FormMain
02.
Public
SerailID
As
String
03.
Private
btnOpenForm2
As
Button
04.
05.
Private
Form2
As
Form
06.
Private
txtSerialID
As
TextBox
07.
Private
btnOK
As
Button
08.
09.
10.
Private
Sub
FormMain_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
11.
12.
Me
.Text =
"FormMain"
13.
14.
btnOpenForm2 =
New
Button()
15.
btnOpenForm2.Text =
"Stock Out"
16.
btnOpenForm2.Location =
New
Point(80, 80)
17.
18.
Form2 =
New
Form()
19.
Form2.Text =
"Form2"
20.
21.
txtSerialID =
New
TextBox()
22.
txtSerialID.Location =
New
Point(80, 50)
23.
24.
btnOK =
New
Button()
25.
btnOK.Text =
"OK"
26.
btnOK.Location =
New
Point(80, 80)
27.
28.
29.
AddHandler
btnOpenForm2.Click,
AddressOf
ButtonOpenForm_Click
30.
AddHandler
btnOK.Click,
AddressOf
ButtonOK_Click
31.
32.
33.
Me
.Controls.Add(btnOpenForm2)
34.
Form2.Controls.Add(txtSerialID)
35.
Form2.Controls.Add(btnOK)
36.
37.
End
Sub
38.
39.
Private
Sub
ButtonOpenForm_Click()
40.
btnOK.DialogResult = Windows.Forms.DialogResult.OK
41.
txtSerialID.Text =
String
.Empty
42.
43.
If
(Form2.ShowDialog() = DialogResult.OK)
Then
44.
MessageBox.Show(SerailID)
45.
46.
End
If
47.
End
Sub
48.
49.
Private
Sub
ButtonOK_Click()
50.
Me
.SerailID = txtSerialID.Text
51.
Form2.Close()
52.
End
Sub
53.
End
Class