Public Class CustomDialog

 

        Private Sub CustomDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            Me.AcceptButton = Button1

            Me.CancelButton = Button2

            Me.TextBox1.Text = ""

 

 

        End Sub

 

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

            Me.DialogResult = Windows.Forms.DialogResult.OK

            Me.Close()

        End Sub

 

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

            Me.Close()

        End Sub

    End Class

Ø      After this enter the following codes for the Form1:

Public Class Form1

        Dim DialogBox As New CustomDialog()

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        End Sub

 

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

            If DialogBox.ShowDialog = Windows.Forms.DialogResult.OK Then

                Me.Label1.Text = DialogBox.TextBox1.Text

 

            End If

 

        End Sub

 

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

            Me.Close()

        End Sub

    End Class