?
Solved

vb.net add to another form from form2

Posted on 2005-04-07
3
Medium Priority
?
307 Views
Last Modified: 2012-05-05
I have a form that has a button on it. Then when the user hits that button it opens up form2. Now on form2 I want a button that will add some text the the label that is on form1. Remember form1 has to remain open

I tried

dim form1 as form1

form1.label1.text = "Hi"

but get and error
any ideas
0
Comment
Question by:bman9111
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 13730586
Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f2 As New Form2
        f2.Owner = Me
        f2.Show()
    End Sub

End Class

Public Class Form2
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f1 As Form1 = CType(Me.Owner, Form1)
        f1.TextBox1.Text = "Hi"
    End Sub

End Class
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13730601
Actually, you said a Label so change

    f1.TextBox1.Text = "Hi"

to

    f1.Label1.Text = "Hi"

but you should get the idea.
0
 
LVL 8

Author Comment

by:bman9111
ID: 13730818
great, thank u. I have been using vb.net 2005, and opening and manipulating forms are so much easier. I can't wait until that is out for sell. It eliminates all this.....

Thanks again
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question