Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
If e.KeyData = Keys.Enter Then
Me.TextBox1.Text = DirectCast(sender, TextBox).Text
DirectCast(DirectCast(sender, TextBox).Parent, Form).Close()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New Form2

AddHandler f.TextBox1.KeyDown, AddressOf TextBox_KeyDown

f.Show()
End Sub
End Class
So, I have two forms, each with a textbox. Form1 has a button which launches Form2. Form1 adds an event handler to the textbox in Form2 so that when you press Enter, it grabs the text and closes Form2. Is this OK to do? I mean, in my little test, it works. But, is this really bad practice?

Also, I cannot use ShowDialog().