locked
Passing value From second & third Form RRS feed

  • Question

  • Hi Friends,

    I am calling from Form1 from  Main Form and then from Form2 from Form1 I want to change texttbox1 (Form1) value from 

    Form2 without recalling the new form of Form1 , I not could pass value code as below

     

    Main Form code


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

     Dim f1 As New Form1
            f1.TextBox1.Text = "From Form1"
            f1.TextBox2.Text = "From Form1"
            f1.ShowDialog()

     End Sub

    Form1 Code as below

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim f2 As New Form2
            f2.TextBox1.Text = "From Form2"
            f2.TextBox2.Text = "From Form2"
            f2.ShowDialog()
        End Sub

    FORM3 CODE 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            
            Form1.TextBox1.Text = "from form2"
            Form1.TextBox2.Text = "from form2"

        End Sub

    Code in form3 not working and value not changing  unless I will call new instance of Form1, I want without calling

    new instance of Form1 the value will be change.

    thank you


    asad

    Wednesday, November 25, 2020 8:18 AM

Answers

  • Try two modifications:

       Dim f1 = Form1

    and

       Dim f2 = Form2

    • Marked as answer by malikasad Wednesday, November 25, 2020 10:05 AM
    Wednesday, November 25, 2020 9:40 AM

All replies

  • Try two modifications:

       Dim f1 = Form1

    and

       Dim f2 = Form2

    • Marked as answer by malikasad Wednesday, November 25, 2020 10:05 AM
    Wednesday, November 25, 2020 9:40 AM
  • What does not working mean?

    I'm pretty sure it works. But did you call Show() for Form1 somewhere?

    • Marked as answer by malikasad Wednesday, November 25, 2020 10:07 AM
    • Unmarked as answer by malikasad Wednesday, November 25, 2020 10:07 AM
    Wednesday, November 25, 2020 9:44 AM
  • no I did not call show form its working fine

    thank you

    regards,

    asad


    asad

    Wednesday, November 25, 2020 10:07 AM
  • thank you its working fine

    asad

    Wednesday, November 25, 2020 10:08 AM