Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ListBox1.Items.AddRange({"Apple", "Banana", "Cat", "Dog"}) End Sub Private Sub ListBox1_DoubleClick(sender As Object, e As System.EventArgs) Handles ListBox1.DoubleClick If ListBox1.SelectedItem Is Nothing Then '何も選択されていなければ何もしない。 Return End If Dim f As New Form2 f.Show(ListBox1.SelectedItem) Me.Close() End Sub Private Sub ListBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles ListBox1.KeyPress If e.KeyChar = Chr(Keys.Enter) Then ListBox1_DoubleClick(sender, e) End If End Sub End Class
Public Class Form2 Public Overloads Sub Show(value As String) Me.TextBox1.Text = value Me.Show() End Sub End Class