473,387 Members | 1,749 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,387 software developers and data experts.

Getting data from a field in another form

When i load a form (frmcontract) in the program i write i can load a contract
(cbocontract) as well as many other things, also in this form i can load
another form to deal with expenditure (frmexpenditure) by pressing a button.
Previously in VB6 i could call the data from the cbocontract field in
frmcontract from frmexpenditure by saying:

whatever=frmcontract.cbocontract.text

In VB.NET i can't do this and no matter how hard i try (obviously not hard
enough) i can't find a way of doing it. How is it done?
Nov 21 '05 #1
3 1671
RBirney,

You can do it in VBNet as well, however it is not good OOP programming. You
make your form classes completly dependable from each other.

Better is to share your data in a whatever global class.
Sample
\\\
Public Class MyData
Public Shared myfield as string
End Class
///

Now you can use myfield everywhere in your project as
MyData.myfield

(This is a the most simple approach just to show you how it goes)

I hope this helps?

Cor
"RBirney" <RB*****@discussions.microsoft.com>
When i load a form (frmcontract) in the program i write i can load a
contract
(cbocontract) as well as many other things, also in this form i can load
another form to deal with expenditure (frmexpenditure) by pressing a
button.
Previously in VB6 i could call the data from the cbocontract field in
frmcontract from frmexpenditure by saying:

whatever=frmcontract.cbocontract.text

In VB.NET i can't do this and no matter how hard i try (obviously not hard
enough) i can't find a way of doing it. How is it done?

Nov 21 '05 #2
RBirney wrote:
When i load a form (frmcontract) in the program i write i can load a contract
(cbocontract) as well as many other things, also in this form i can load
another form to deal with expenditure (frmexpenditure) by pressing a button.
Previously in VB6 i could call the data from the cbocontract field in
frmcontract from frmexpenditure by saying:

whatever=frmcontract.cbocontract.text

In VB.NET i can't do this and no matter how hard i try (obviously not hard
enough) i can't find a way of doing it. How is it done?


Is frmcontract visible to your frmexpenditure? IOW, is that a global
variable? If not, then frmexpenditure doesn't know that variable and the
code doesn't work. Now if you always call frmexpenditure only from
frmcontract, you could try me.parent.cbocontract.text, presuming you
called the form as follows from frmcontract:

dim frmExpenditure as new clsExpenditure() 'I always call my form
clsSomething so I can call the referring vars frmSomething
frmExpenditure.showdialog(me)

or something similar.

Another way could be to define a public var in your frmexpenditure like
Dim cContract as String()

Then in frmContract do something like:
dim frmExpenditure as new clsExpenditure()
frmExpenditure.cContract="whatever"
frmExpenditure.showdialog(me)

Then you'd have a var cContract available in your Expenditure form.

Rinze van Huizen
Nov 21 '05 #3
"Cor Ligthert" <no************@planet.nl> schrieb:
Better is to share your data in a whatever global class.
Sample
\\\
Public Class MyData
Public Shared myfield as string
End Class
///

Now you can use myfield everywhere in your project as
MyData.myfield

(This is a the most simple approach just to show you how it goes)


Yep. Notice that by using this approach the same field will be shared
between all instances of 'MyData'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
15
by: U N Me | last post by:
I have a continuous form that lists records from a query. One of the columns is an amount field, In the footer of the form I place a text box that displays the total (sum) of the amount. The...
11
by: David Messner | last post by:
Ok I know this is simple but the statement eludes me... I have a date field where I want the default value on the data entry form's date field to be the last date entered. I figure I can do this...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
4
by: Cerebral Believer | last post by:
Hi I need help! Forgive me I am a PHP newbie. I have a small script that enables me to send a form from an HTML page. I want to use the HTML formatted form because the design of my website is...
2
by: shadowman | last post by:
So here's the situation: I need to write a PHP script which accepts form submissions using all methods (GET and POST) and all content types (application/x-www-form-url-encoded and...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
2
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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
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.