I am just learning VB.Net and I'm having a problem with one of the exercises. The excersie is a simple textbox example using two forms (Form1 & Form2).

> Form1 holds a text box (TextBox1) and an Options button.

> TextBox1 is instantiated as follows (This is extracted IDE code):

Public WithEvents TextBox1 As System.Windows.Forms.TextBox

Me.TextBox1 = New System.Windows.Forms.TextBox

Me.TextBox1.Font = New System.Drawing.Font("Arial", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, _ CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(8, 8)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(512, 504)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""

> The click event of the options button instantiates a new Form2 as follows:
Dim N As New Form2
N.ShowDialog()

> Form2 consistes of two groups of radio buttons (Color and Border Style) and two buttons (Accept & Cancel).

> The click event of Accept button tests the states of the radio buttons and sets the attributes of Form1.TextBox1 according using the following code (line continuation added) :

Dim N As New Form1
If rbBlue.Checked = True Then TextBox1.ForeColor = _ System.Drawing.Color.Blue

If rbRed.Checked = True Then N.TextBox1.ForeColor = _ System.Drawing.Color.Red

If rbGreen.Checked = True Then N.TextBox1.ForeColor = _ System.Drawing.Color.Green

If rbBlack.Checked = True Then N.TextBox1.ForeColor = _ System.Drawing.Color.Black

If rbBorder3D.Checked = True Then N.TextBox1.BorderStyle = _ System.Windows.Forms.BorderStyle.Fixed3D

If rbBorderFlat.Checked = True Then N.TextBox1.BorderStyle = _ System.Windows.Forms.BorderStyle.FixedSingle

Me.Hide()

** The application runs without any problems (i.e. no compile or runtime errors) but if you set the color and border style options on Form2 (Options Form), when Form2 closes the attributes of Form1.TextBox1 have not changed.

I've experimented by placing code for chaging the attributes for TextBox1 directly in the Form1.Options button and it works perfectly, however, I want to make it work as it was intended.

I've also tried adding a N.Show() command at the end of the Accept button on Form2. This shows the new instance of Form1 (N) with the TextBox attributes correctly set but I now have two instances of Form1 showing!

I want to be able to set the attributes of a TextBox on one form, from another form.

I'm sure this is fairly simple but I just cant figure out what I'm doing wrong.

Anyone, Please help.

Email: [email protected]

Rob C