Passing Control Values between forms using VB.NET

W

Wayne Taylor

Hello all.....

I'm having a hard time understanding how to read/write to the contents of controls on diffient forms.
If I create a Windows Form project with two forms..... add a text box to each...now I add the following code to form1.....

Public Class Form1
Inherits System.Windows.Forms.Form
Dim f2 As New Form2

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
f2.Show()
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
f2.TextBox1.Text = TextBox1.Text
End Sub

End Class

So when you run the app, what ever you type in form1, textbox1's control will appear in form2, textbox1 control....

What I can't do is make it so that what's typed in form2, textbox1 appears in form1, textbox1....

This is only practice code, I don't want to do this in live project, I'm just trying to get my head around it.....


Thanks in advance, hope that makes sense.

Wayne Taylor (kryptos)

If you wish to e-mail me, then please remove 'online' from my e-mail addy.
 
C

Cor Ligthert

Hi Wayne,

When you use showdialog have a look at the answer I gave to Mike Johnson in
the row above this messagethread, if you use "show" have a look at the
answer from Herfried some messages below to Mike Johnson.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top