473,397 Members | 2,099 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,397 software developers and data experts.

Two forms sharing data

I have a project consisting of two forms and a class that
I created. The class, called Project, has several
properties and a method. Form1 instantiates my Project
class and populates the properties from textboxes. When
the user presses the Next button, Form2 should display the
data in the class properties. I'm getting an error in
Form2 because the class object hasn't been referenced.

I'm new to the .NET environment. Could someone point me
in the right direction?

Thanks much.
Jul 21 '05 #1
4 1168
Hi Dave,
I know that you instantiated the class in Form1, but
where did you declare the variable used to instantiate the
class and what modifier did you use? Carol
-----Original Message-----
I have a project consisting of two forms and a class that
I created. The class, called Project, has several
properties and a method. Form1 instantiates my Project
class and populates the properties from textboxes. When
the user presses the Next button, Form2 should display thedata in the class properties. I'm getting an error in
Form2 because the class object hasn't been referenced.

I'm new to the .NET environment. Could someone point me
in the right direction?

Thanks much.
.

Jul 21 '05 #2
My code looks like this:
Public Class frmMain
Inherits System.Windows.Forms.Form
Public objProject as New Project()
....
-----Original Message-----
Hi Dave,
I know that you instantiated the class in Form1, but
where did you declare the variable used to instantiate theclass and what modifier did you use? Carol
-----Original Message-----
I have a project consisting of two forms and a class thatI created. The class, called Project, has several
properties and a method. Form1 instantiates my Project
class and populates the properties from textboxes. When
the user presses the Next button, Form2 should display

the
data in the class properties. I'm getting an error in
Form2 because the class object hasn't been referenced.

I'm new to the .NET environment. Could someone point me
in the right direction?

Thanks much.
.

.

Jul 21 '05 #3
Hi Dave,
Declare your object variable in a module. So add a module
to your project and declare it there. You can set it as
friend if your object is only used within your project.
If you have multiple projects in your solution and you
want to make it available to all projects, make it
public.

Carol
-----Original Message-----
My code looks like this:
Public Class frmMain
Inherits System.Windows.Forms.Form
Public objProject as New Project()
....
-----Original Message-----
Hi Dave,
I know that you instantiated the class in Form1, but
where did you declare the variable used to instantiate

the
class and what modifier did you use? Carol
-----Original Message-----
I have a project consisting of two forms and a classthatI created. The class, called Project, has several
properties and a method. Form1 instantiates my Project
class and populates the properties from textboxes. Whenthe user presses the Next button, Form2 should display

the
data in the class properties. I'm getting an error in
Form2 because the class object hasn't been referenced.

I'm new to the .NET environment. Could someone point mein the right direction?

Thanks much.
.

.

.

Jul 21 '05 #4
On Fri, 24 Oct 2003 06:07:49 -0700, DaveE wrote:
class and populates the properties from textboxes. When
the user presses the Next button, Form2 should display

the
data in the class properties. I'm getting an error in
Form2 because the class object hasn't been referenced.


Overload the constructor of Form2 to take an instance of your project class
and when you create form2, pass in the instance that you created in Form1:

Public Class frmMain
Inherits System.Windows.Forms.Form
Public objProject as New Project()

Dim f2 As New Form2(objProject)

f2.Show

'In Form2:

Public Sub New(o As Project)
'Do something with o here
End Sub

HTH

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Jul 21 '05 #5

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

Similar topics

6
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
2
by: Red Green | last post by:
I am trying to switch to C# from Delphi and I am having some trouble finding some information. What I need to do should be simple but I have been through a dozen books and done web searches that...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
4
by: Greg Burns | last post by:
I have built a web app that uses forms authentication. There isn't a "remember me" feature (i.e. the authentication cookie is not permanent). When you close the browser, and open a new one, you...
2
by: Mervin Williams | last post by:
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form on each, and these web forms will share data. ...
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
5
by: Sebastian | last post by:
Hello, I am attempting to share forms authentication between two applications but running into problems. The documentation I've been able to dig up says (to summarize) if the the Web.Config...
9
by: WebCM | last post by:
I need a solution for CMS. I would like to edit and create FORMS easily, especially list of settings. Which is better and why? $$ XML or HTML $$ Forms occur in View layer - in presentation file....
9
by: kirk | last post by:
I have program.cs, my "main" form and then a "settings" form. My "main" form existed for awhile and I had constants, instantiations, properties, etc within it created. I went to create my...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.