Simple question

A

Al

I have 2 forms - Form1 and Form2

I open Form2 from Form1 by doing this:

dim frm as Form2
frm=new Form2
frm.ShowDialog

I need to change the Button1.Text on the Form1 from Form2.
I'm trying :
dim frmCaller as Form1
frmCaller=new Form1
frmCaller.Button1.Text="Something"

The text of Button1 on Form1 doesn't change
I suspect that I do not connect to the existing Form1, I just create a new
instance of the Form1 and change Button1.Text in it. Because I see that in
debug mode the text property is changed, but it's not on the screen.

In VB6 assigning Caption of the Button from another form was pretty simple -
Form1.Caption = "Something". That's it.
How is it done in VB2005?

Thank you
Al
 
G

Guest

Al,

Form2 needs a reference to Form1.

One option is to create a property on Form2 similar to this:

Public frmCaller as Form1

Then, on Form1, supply the reference before showing Form2:

dim frm as Form2
frm=new Form2
frm.frmCaller = Me
frm.ShowDialog

Now Form2 can click a button on Form1:

frmCaller.Button1.Text="Something"

Kerry Moorman
 

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

Similar Threads


Top