| | |
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 |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel file-dialog firewall folder ftp google hardcopy image images insert isnumericfuntioncall listview login math memory mobile ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problemwithinstallation project reports" save savedialog searchbox serial soap sorting string table tcp temp text textbox timer toolbox trim update updown upload useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





