Forms in general (a simple question)

G

Guest

It is really a simple question.

Visual Basic .NET (2003)

I create 2 forms (Form1 and Form2)

I create a checkbox in Form1 (checkbox1)
I create a checkbox in Form2 (checkbox1)
I go to Form1 doubleclick on checkbox1 and alters the code

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles CheckBox1.CheckedChanged
' here begin the alteration
If CheckBox1.Checked = True Then
Form2. ' here begins the problem, i want to set the control in
form2 the same as in form1


End If
End Sub

The question is very simple
Why can i not refer to a control in form2 from form1. there was no problem
in VB6
 
C

Chris Dunaway

You can refer to a control in Form2 but you must have a reference to
Form2 in order to do. How are you creating your reference to Form2?
Somewhere in your code you must have something similar to this:

Dim MyForm2 As New Form2


Then you can access the checkbox on Form2 like this:

MyForm2.Checkbox1.Checked = True

Hope this helps

Chris
 

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