| | |
help accessing control from a different form
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2008
Posts: 29
Reputation:
Solved Threads: 1
Hello everyone. I have been studying VB on my own in prep for my class next semester. I am trying to update a label on form1 from form2. Below is just a "test" example i created to figure out what im doing wrong. It is not the actual project i am working on.
this is the form1 code
this is the second form code. am i accessing this wrong or declaring something else incorrectly? If you need anymore info,let me know. All i have is one button on the first form opening the second form. This form has a button that when i click it, i want to update the label in form1. Thanks you in advance.
this is the form1 code
vb Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm2 As New Form2() frm2.Show() End Sub
this is the second form code. am i accessing this wrong or declaring something else incorrectly? If you need anymore info,let me know. All i have is one button on the first form opening the second form. This form has a button that when i click it, i want to update the label in form1. Thanks you in advance.
VB Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm1 As New Form1() frm1.lblTest.Text = "Hello" End Sub
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Well, it depends. Are you destroying Form1 when you go to Form2? If you are then you are right. I feel though that you are not, so, what you have is Form1 and Form2 and then creating frm1.
Delete the line:
Dim frm1 As New Form1()
and change the next line to:
Form1.lblTest.Text = "Hello"
If you are using vb 2005 or vb 2008 then you don't need to create a new form. Just use:
Form2.Show()
Delete the line:
Dim frm1 As New Form1()
and change the next line to:
Form1.lblTest.Text = "Hello"
If you are using vb 2005 or vb 2008 then you don't need to create a new form. Just use:
Form2.Show()
Last edited by waynespangler; Dec 19th, 2008 at 4:31 am.
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
![]() |
Similar Threads
- accessing ms access from VB (Visual Basic 4 / 5 / 6)
- Can someone please tell me what I am doing wrong? (VB.NET)
- Script raises Page error when accessing HTML control (ASP.NET)
- Accessing Oracle stored functions from asp.net (ASP.NET)
- Connectivity of SQL 2000 + VB using ODBC (Visual Basic 4 / 5 / 6)
- JavaScript form validation - please help (JavaScript / DHTML / AJAX)
- loadin a form (Visual Basic 4 / 5 / 6)
- Accessing objects that are not in the form fields (JavaScript / DHTML / AJAX)
- Accessing Non-form Variables (JavaScript / DHTML / AJAX)
- XP Professional Desktop Icon Malfunction (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: Open Browser from VB.NET
- Next Thread: Multithreaded / asynch SQL
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array arrays basic bing button buttons c# center check checkbox code convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters picturebox picturebox1 port position print printing problem project read remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer timespan toolbox trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





