Wednesday, July 13, 2011

Passing parameter in vb.net from child form to parent

passing parameter from child to parent is little hard than passing from parent to child

in vb.net

follow the following

Declare Private form level variable in child form

Private strData As String

and also create public property to set and get this variable.

Public Property AnyName() as string
Get
Return strData
End Get

Set(ByVal value As String)
strData=value
End Set
End Property


That's All

now you can test it from in your Command Button or any other child calling event parent as :

Dim dlg As New frmName : dlg.ShowDialog()

If dlg.AnyName <> "" Then MsgBox(dlg.AnyName)