Question:

How to pass the textbox values to form 1 to form 2 in VB.net

by  |  earlier

0 LIKES UnLike

am new to VB.net 2005

I am facing one problem with,could you pls help me out!!

In form1

i have created textboxe1,textbox2,textbox3 and one button.

i have written code like this

Public class Form1

Dim x1 as Double

Dim x2 as Double

Private sub Button1_Click(Byval.......)..

textbox1.text=x1

textbox2.text=x2

textbox3.text= x1 x2

end Sub

End class

My Problem is ,i wanted to see the textbox 3 value in the Form2.

 Tags:

   Report

1 ANSWERS


  1. we'll you need a constructor in which you'll pass values from FORM1 to your FORM2.

    so heres an idea.

    IN your FORM2 code. create a constructor has 1 parameter. sample:

    Public class FORM2

    Public Sub New(ByVal value As String)

    'constructor

    x = value

    'storing the value of x in constructor

    End Sub

    End class

    so in your FORM1 button click

    Private sub Button1_Click(Byval.......)..

    textbox1.text=x1

    textbox2.text=x2

    textbox3.text= x1 x2

    dim Form2 as new Form2(textBox3.Text)

    Form2.show

    end Sub

    hope this helps

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.