Pass value from one form to another form VB

  • 0
  • Pass value from one form to another form
  1. In Form 1, copy this code to button click event:

  2. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles             Button1.Click
          Dim frm As New Form2()
          frm.idinF2 = Me
          frm.ShowDialog()
    End Sub

  3. In Form 2, copy this code:

  4. Public Class Form2

          Inherits System.Windows.Forms.Form
          Public idincom As applicantedit

          Public Sub New()
                InitializeComponent()
          End Sub

          Public Sub New(strParam As String)
                InitializeComponent()
                Me.pid.Text = strParam
          End Sub

          Private Sub passportmenu_Load(sender As System.Object, e As System.EventArgs) Handles     MyBase.Load
                Me.pid.Text = DirectCast(Me.idincom, applicantedit).naid.Text
          End Sub

    End Class

No comments: