473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting Text on Different Form

I have two forms, the first having a label and a button that opens the
second form. The second form has a button that I want to set text in
form1's label before closing.
I have no problem getting the 2nd form to show, but when I click the
2nd form's button to set the text in the 1st form's label, I get the
following message:
Object reference not set to an instance of an object.
What am I doing wrong????
Dec 14 '07 #1
2 1466
On Dec 14, 4:01 pm, Fred <fred_coo...@yahoo.comwrote:
I have two forms, the first having a label and a button that opens the
second form. The second form has a button that I want to set text in
form1's label before closing.
I have no problem getting the 2nd form to show, but when I click the
2nd form's button to set the text in the 1st form's label, I get the
following message:
Object reference not set to an instance of an object.
What am I doing wrong????
If the 1st form the application's main form? If so how is it shown? Is
it being shown because it is the project's startup object? If so, then
the reference to the form will not be known to any other class in the
project. If the application's startup object is a Sub Main, and the
form is shown by invoking the Application.Run method in the Sub Main
and passing a reference to the main form to the Applicaiton.Run
method, then it becomes a global reference where any other class in
the project can access it, and any Public or Friend object in it.
Controls in VB are declared as Friend by default.
Dec 14 '07 #2
Fred wrote:
I have two forms, the first having a label and a button that opens the
second form. The second form has a button that I want to set text in
form1's label before closing.
I have no problem getting the 2nd form to show, but when I click the
2nd form's button to set the text in the 1st form's label, I get the
following message:
Object reference not set to an instance of an object.
What am I doing wrong????
In Form2, prefix the label with the Form Name -

Form1.Label1.Text = "Hello"
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bagsmode | last post by:
Hi, I'm trying to set a session cookie and then redirect, however I get the error: Status: 302 Moved Location: /index.cgi I thought I recall getting an error like this when I first tried...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
6
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
1
by: Rachel Suddeth | last post by:
I have an form where the whole display is a tab control (well, that plus a status bar.) I want to set the focus to the first TextBox on the first TabPage when it loads. I tried to put that into...
14
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
8
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to...
2
by: insanity | last post by:
Can anyone help me with a problem that I have with apparently unrelated text disappearing in IE7 when I set a className. This does not happen in Firefox. I am trying to create an Ajax driven...
1
by: eBob.com | last post by:
After a lot of debugging effort I have to conclude that it does. Or at least can. I take a substring (RichTextBox.Text.Substring) before setting SelectionStart and after and get a different...
8
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.