| | |
help accessing control from a different form
Thread Solved |
•
•
Join Date: Oct 2008
Posts: 32
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 3: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
Views: 670 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access ado.net application array arrays asp.net basic bindingsource browser c# center checkbox client code combobox connection control convert crystal crystalreport data database datagrid datagridview dataset datatable date datetimepicker design designer dissertation dissertations error excel exists file form gridview image images insert listview login loops mobile ms msaccess net objects openxml path port print printing problem read save search security serial server settings shutdown sms socket sorting sql statement studio syntax tagging tags textbox time timer type update upload user validation vb vb.net vb2008 view visual visual-studio visualbasic visualstudio2008 vs2008 web web-site webbrowser windows winforms wpf xml





