473,386 Members | 2,129 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,386 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 1166
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.