0

I have created 2 forms (Parent & Child), i want to store the unique textbox value to a variable into the parent form.

Also like this:

Parent Code:

dim passed_value = new childform()
passed_value.show()

On close:

refresh passed_value variable using childform textbox value.

2 Answers 2

1

You can Do the Following to accomplish the Task :

  • Declare a String variable in the child form.
    Public value As String
  • Use ShowDialog() in the Main Form to show the Child form.
    Dim frm As New Form2
    frm.ShowDialog()
  • [Set the value in your form as per your needs]
    value = "New Value"
  • Now get the value variable from the Child form and set the textbox text according to it.
    TextBox1.Text = frm.value
0
1

I would make it a property and give it the necessary access, which to me looks to be ReadOnly.

Private _myValue As DataType

Public ReadOnly Property MyValue() As DataType
Get
    Return _myValue
End Get

You could access it as such: myForm.MyValue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.