How to activate an instance of form?

I'm VB 6 programmer. Now I start to writte code in VB.Net. I'm working on one MDI application and I have a problem. I want to reference on an instance of form, but I don't know how. For example: I have three forms. From Form1 I call Form2 and Form3. On Form2 I have one textbox and on Form3 I have a button.
When I press button on Form3 I want to be written some text in textbox on Form2. I have next code on click_button on Form3:

Dim frm as frmForm2

frm.TextBox1.Text = "Help meeeeeeeeeeeeeeeeeeeeee!"

Best regards!

Dora

Comments

  • I have refered back to previous forms to check to see if an object has a certain value (for searching a database actually). I have not tried to change anything on the previous form, but what i did may help.

    What I did was shared the object ... lets say a checkbox. So in the code that VB generates I changed the "Friend WithEvents" to "Public Shared WithEvents." Then when I refernce the object I just type in the code of a button: formname.checkbox.Checked = "True" and went from there.

    There are 2 pitfalls i'm coming up with though. When I shared the object I cannot see it in the design window (which can be corrected for a while by deleting "Shared" from what you typed in eariler. Secondly... after a few times of running my code my shared boxes sometimes delete themselves. I don't know if this is a problem in othe VBs... but it is a pain here... It took me a long while to figure out what happened. NOw this doesn't happen all the time and I don't know if it will happen once it is deployed.

    Hope it helps.


    : I'm VB 6 programmer. Now I start to writte code in VB.Net. I'm working on one MDI application and I have a problem. I want to reference on an instance of form, but I don't know how. For example: I have three forms. From Form1 I call Form2 and Form3. On Form2 I have one textbox and on Form3 I have a button.
    : When I press button on Form3 I want to be written some text in textbox on Form2. I have next code on click_button on Form3:
    :
    : Dim frm as frmForm2
    :
    : frm.TextBox1.Text = "Help meeeeeeeeeeeeeeeeeeeeee!"
    :
    : Best regards!
    :
    : Dora
    :
    :

  • : I'm VB 6 programmer. Now I start to writte code in VB.Net. I'm working on one MDI application and I have a problem. I want to reference on an instance of form, but I don't know how. For example: I have three forms. From Form1 I call Form2 and Form3. On Form2 I have one textbox and on Form3 I have a button.
    : When I press button on Form3 I want to be written some text in textbox on Form2. I have next code on click_button on Form3:
    :
    : Dim frm as frmForm2
    :
    : frm.TextBox1.Text = "Help meeeeeeeeeeeeeeeeeeeeee!"
    :
    : Best regards!
    :
    : Dora
    :

    --
    hi,

    u missed a small thing.
    ur declaration is wrong.
    VB .NET is OOPS. So u need to use the NEW Keyword when ever u create an object.

    Dim frm as NEW frmForm2

    frm.TextBox1.Text = "Help meeeeeeeeeeeeeeeeeeeeee!"


    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories