G
Guest
I am reading the book Teach Yourself Microsoft Visual Basic .Net 2003 in 21
Days.
I am having trouble getting one of the exercises to work at the end of day 4.
Exercises:
1. Create a new multiple-form application that displays two forms when it
starts, each
with a text box. Add code to each text box’s TextChanged event (this is the
default
event for text boxes, which occurs when the text in the text box changes;
just double-
click a text box to bring this event handler up in a code designer) so that
when
you change the text in one text box, the new text also appears automatically
in the
text box in the other form, keeping the two text boxes in the two different
forms
synchronized.
This is what I have:
I have my main form "Form1" with a textbox which is loaded at the
application start. I have a second form "Form2" with a textbox that I load
in "Form1's" onload event handler by creating a new instance of "Form2". Now
I have no problem getting what is typed in "Form1's" textbox to show up in
the new instance of "Form2". I have having a problem getting what is typed
in "From2's" textbox to show up in "Form1's" textbox. This is just supposed
to be basic code to use to do this, but I am not sure howto get access to
"From1" from inside the instance of "Form2" that I created.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
-Deleted to shorten post
#End Region
Dim frmTwo As New Form2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
frmTwo.Show()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged
frmTwo.TextBox1.Text = Me.TextBox1.Text
End Sub
End Class
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
-Deleted to shorted post
#End Region
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged
'I am not sure how to get access to Form1.textbox1.text from inside
here
End Sub
End Class
Thanks
Days.
I am having trouble getting one of the exercises to work at the end of day 4.
Exercises:
1. Create a new multiple-form application that displays two forms when it
starts, each
with a text box. Add code to each text box’s TextChanged event (this is the
default
event for text boxes, which occurs when the text in the text box changes;
just double-
click a text box to bring this event handler up in a code designer) so that
when
you change the text in one text box, the new text also appears automatically
in the
text box in the other form, keeping the two text boxes in the two different
forms
synchronized.
This is what I have:
I have my main form "Form1" with a textbox which is loaded at the
application start. I have a second form "Form2" with a textbox that I load
in "Form1's" onload event handler by creating a new instance of "Form2". Now
I have no problem getting what is typed in "Form1's" textbox to show up in
the new instance of "Form2". I have having a problem getting what is typed
in "From2's" textbox to show up in "Form1's" textbox. This is just supposed
to be basic code to use to do this, but I am not sure howto get access to
"From1" from inside the instance of "Form2" that I created.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
-Deleted to shorten post
#End Region
Dim frmTwo As New Form2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
frmTwo.Show()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged
frmTwo.TextBox1.Text = Me.TextBox1.Text
End Sub
End Class
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
-Deleted to shorted post
#End Region
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged
'I am not sure how to get access to Form1.textbox1.text from inside
here
End Sub
End Class
Thanks