473,386 Members | 1,606 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.

VB.NET: Transferring Data From Form to Form

Does anyone have any idea how to transferring data from TextBox1 in form1 to
textBox2 in form2.....

That means after i fill in any data in textBox1 and click Next button...

It will bring me to form2....and there the data that i key in form1 will
appear to form2 in textbox2
Thanks

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum
Nov 21 '05 #1
15 5054
You must declare a Public variable, or else change the textbox declaration
to Public.

Then in form 2 you will be able to access the public members of Form1.

--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"http://www.visual-basic-data-mining.net/forum" <si******@gmail.com> wrote
in message news:%2***************@tk2msftngp13.phx.gbl...
Does anyone have any idea how to transferring data from TextBox1 in form1
to
textBox2 in form2.....

That means after i fill in any data in textBox1 and click Next button...

It will bring me to form2....and there the data that i key in form1 will
appear to form2 in textbox2
Thanks

--
toytoy - forum member
http://www.visual-basic-data-mining.net/forum

Nov 21 '05 #2
Hi,

This question from you, gives forever a lot of messages.
Very important is where you create your "other" form and how you do that.

(There are a lot of ways to do that in VBNet)

When that is known than it is a piece of cake to help you mostly.

Maybe you can show us that.

Cor
Nov 21 '05 #3
"Cor Ligthert" <no************@planet.nl> wrote in message news:<OK**************@TK2MSFTNGP10.phx.gbl>...
This question from you, gives forever a lot of messages.
Very important is where you create your "other" form and how you do that.


Regardless of where and how the "other" form is created, the best
method of passing data to a form for display is either by a property
or method of that form. The issue here is "How do I pass data to a
given form?"

In my opinion, public variables (that is global to the whole
application) should rarely be used. It is also my opinion that it is
not a good idea to make UI objects of a form public. It would be
better to create a form or a method for the form that is to accept the
data for display.

"Where" and "how" a form is created will simply determine where your
*reference* to that form is. However, that is a different issue. The
issue of when and where a form is created is "How do I reference a
form I've already created or am about to create?"
Nov 21 '05 #4
"Cor Ligthert" <no************@planet.nl> wrote in message news:<OK**************@TK2MSFTNGP10.phx.gbl>...
This question from you, gives forever a lot of messages.
Very important is where you create your "other" form and how you do that.


Regardless of where and how the "other" form is created, the best
method of passing data to a form for display is either by a property
or method of that form. The issue here is "How do I pass data to a
given form?"

In my opinion, public variables (that is global to the whole
application) should rarely be used. It is also my opinion that it is
not a good idea to make UI objects of a form public. It would be
better to create a form or a method for the form that is to accept the
data for display.

"Where" and "how" a form is created will simply determine where your
*reference* to that form is. However, that is a different issue. The
issue of when and where a form is created is "How do I reference a
form I've already created or am about to create?"
Nov 21 '05 #5

"DenBorg" <de******@yahoo.com> wrote
This question from you, gives forever a lot of messages.
Very important is where you create your "other" form and how you do that.


Regardless of where and how the "other" form is created, the best
method of passing data to a form for display is either by a property
or method of that form. The issue here is "How do I pass data to a
given form?"

I'll add my vote for either of those:

Dim OF As New OtherForm
' A method of the form
OF.SetData("Use this data" [, "Any other data"] )

Or;

' A property of the form
OF.RequiredData = "Use this data"
(methods are in order of preference)
LFS
Nov 21 '05 #6
DenBorg,

I never have a "best" method all is dependable from the situation.

I write forever here that in this the most advised method is using
properties.

When there were best methods the language would be very poor.

However the question was not what is the best, however "How" which means
that you should first get to the reference of the form before you can pass
anything. Will I show you the threads where people have trouble with that.
When there is no reference to the object, the property in that is
unreachable and you can not pass.

I hope this helps?

Cor
"DenBorg" <de******@yahoo.com>
Nov 21 '05 #7
> "Where" and "how" a form is created will simply determine where your
*reference* to that form is. However, that is a different issue. The
issue of when and where a form is created is "How do I reference a
form I've already created or am about to create?"


Yes therefore my question, from which you say that that is not needed.
This reference has more than one method depending on the is created form or
to create form.

I hope this helps?

Cor
Nov 21 '05 #8
> When there were best methods the language would be very poor.

I disagree. There are fundamental programming principles that are
universally applicable.

Let me give you one over-simplistic illustration. Suppose the
objective is to repeat a certain process several times. In my opinion,
the second of the following methods is clearly the best method:

'Method #1
DoSomething()
DoSomething()
DoSomething()
DoSomething()
DoSomething()
DoSomething()

'Method #2
Dim Index As Integer
For Index = 1 To 6
DoSomething()
Next 'Index

I am certain you would believe that the second method is clearly and
undoubtably better. But does that make Visual Basic a "very poor"
language just because Method #2 is better than Method #1? Of course
not.

By the same token, using Application Global variables is ill advised
in any programming language. And other means of transfering data from
one object to another is recommended and considered "better" than the
use of global variables.

Consider OOP programming verses linear programming. OOP was designed
to provide "better" methods of working with data and code. But instead
of making languages "very poor", these "better" designs makes these
languages "very good".

However the question was not what is the best, however "How" ...
Certainly you are not suggesting that when asked "How" we should offer
suggestions that are bad! Whenever someone asks me "How", I always try
to give them the best answer possible. And just because the person did
not explicitly ask for the "best", that does not mean that the person
wants "bad" answers.

However the question was not what is the best, however "How" which means
that you should first get to the reference of the form before you can pass
anything.
Yes, it is quite obvious that you must first have a reference to the
form before you can pass any information to it. However, having or
getting the form's reference has no bearing on how you should pass the
information to the form. They are two totally different issues.

Think about it this way. Suppose you create a form (named OtherForm)
at the same time you need to pass data to it. And let's say you create
a property named Data for the purpose of passing data to that form.
Your code would look something like the following:

Dim OF As New OtherForm

OF.Data = "data"

Now suppose that instead of creating OtherForm at the time you pass
data to it, you instead create OtherForm earlier on, and now need to
pass data to it. In other words, you need to data to a form that is
*already* opened.

My question to you is this: Should you change your method of passing
data to OtherForm simply because you changed when OtherForm is
created? Is using a property now a bad idea simply because OtherForm
is already loaded?

In other words, would you use one method of passing data (such as
global variables) to forms that were created at the start of the
program, but use a different method of passing data (such as
properties) to pass data to forms that are created immediately prior
to passing data to it?

My point is this: The method you use to pass data to a form is not
determined by when the form is created.
Will I show you the threads where people have trouble with that.
When there is no reference to the object, the property in that is
unreachable and you can not pass.


Again, this is blatantly obvious.

You don't have to know *when* the form is created, nor where the
form's reference is, before you can suggest methods of passing data to
the form.
Make sense?
-Dennis Borg
Nov 21 '05 #9
> When there were best methods the language would be very poor.

I disagree. There are fundamental programming principles that are
universally applicable.

Let me give you one over-simplistic illustration. Suppose the
objective is to repeat a certain process several times. In my opinion,
the second of the following methods is clearly the best method:

'Method #1
DoSomething()
DoSomething()
DoSomething()
DoSomething()
DoSomething()
DoSomething()

'Method #2
Dim Index As Integer
For Index = 1 To 6
DoSomething()
Next 'Index

I am certain you would believe that the second method is clearly and
undoubtably better. But does that make Visual Basic a "very poor"
language just because Method #2 is better than Method #1? Of course
not.

By the same token, using Application Global variables is ill advised
in any programming language. And other means of transfering data from
one object to another is recommended and considered "better" than the
use of global variables.

Consider OOP programming verses linear programming. OOP was designed
to provide "better" methods of working with data and code. But instead
of making languages "very poor", these "better" designs makes these
languages "very good".

However the question was not what is the best, however "How" ...
Certainly you are not suggesting that when asked "How" we should offer
suggestions that are bad! Whenever someone asks me "How", I always try
to give them the best answer possible. And just because the person did
not explicitly ask for the "best", that does not mean that the person
wants "bad" answers.

However the question was not what is the best, however "How" which means
that you should first get to the reference of the form before you can pass
anything.
Yes, it is quite obvious that you must first have a reference to the
form before you can pass any information to it. However, having or
getting the form's reference has no bearing on how you should pass the
information to the form. They are two totally different issues.

Think about it this way. Suppose you create a form (named OtherForm)
at the same time you need to pass data to it. And let's say you create
a property named Data for the purpose of passing data to that form.
Your code would look something like the following:

Dim OF As New OtherForm

OF.Data = "data"

Now suppose that instead of creating OtherForm at the time you pass
data to it, you instead create OtherForm earlier on, and now need to
pass data to it. In other words, you need to data to a form that is
*already* opened.

My question to you is this: Should you change your method of passing
data to OtherForm simply because you changed when OtherForm is
created? Is using a property now a bad idea simply because OtherForm
is already loaded?

In other words, would you use one method of passing data (such as
global variables) to forms that were created at the start of the
program, but use a different method of passing data (such as
properties) to pass data to forms that are created immediately prior
to passing data to it?

My point is this: The method you use to pass data to a form is not
determined by when the form is created.
Will I show you the threads where people have trouble with that.
When there is no reference to the object, the property in that is
unreachable and you can not pass.


Again, this is blatantly obvious.

But you don't have to know *when* the form is created, nor where the
form's reference is, before you can suggest methods of passing data to
the form.
Make sense?
-Dennis Borg
Nov 21 '05 #10
I hope this doesn't double post. I got an error message on my first
attempt, plus I think this post will be more concise and clearer.
When there were best methods the language would be very poor.
I disagree. There are fundamental programming principles that are
universally applicable.

Let me give you one over-simplistic illustration. Suppose the
objective is to repeat a certain process several times. In my opinion,
the second of the following methods is clearly the best method:

'Method #1
DoSomething()
DoSomething()
DoSomething()
DoSomething()
DoSomething()
DoSomething()

'Method #2
Dim Index As Integer
For Index = 1 To 6
DoSomething()
Next 'Index

I am certain you would agree that the second method is clearly and
undoubtably better. But does that make Visual Basic a "very poor"
language just because Method #2 is better than Method #1? Of course
not.

By the same token, using Application Global variables is ill advised
in any programming language. And other means of transfering data from
one object to another is recommended and considered "better" than the
use of global variables.

And consider OOP programming verses linear programming. OOP was
designed to provide "better" methods of working with data and code.
But instead of making languages "very poor", these "better" designs
makes these languages "very good".
However the question was not what is the best, however "How" ...
Whenever someone asks me "How", I always try to give them the best
answer possible. And just because the person did not explicitly ask
for the "best", that does not mean that the person wants "bad"
answers.

Again, the question was, and I am directly quoting the Original
Poster, "how to transferring data from TextBox1 in form1 to textBox2
in form2"

My point is that regardless of *when* Form2 is created, the "HOW TO"
of transferring data from Form1 to Form2 would be the same.
However the question was not what is the best, however "How" which means
that you should first get to the reference of the form before you can pass
anything.
Yes, it is quite obvious that you must first have a reference to the
form before you can pass any information to it. However, having or
getting the form's reference has no bearing on how you should pass the
information to the form. They are two totally different issues.

Think about it this way. Suppose you create a form (named OtherForm)
at the same time you need to pass data to it. And let's say you create
a property named Data for the purpose of passing data to that form.
Your code would look something like the following:

Dim OF As New OtherForm

OF.Data = "data"

Now suppose that instead of creating OtherForm at the time you pass
data to it, you instead create OtherForm earlier on, and now need to
pass data to it. In other words, you need to data to a form that is
*already* opened.

My question to you is this: Should you change your method of passing
data to OtherForm simply because you changed when OtherForm is
created? Is using a property now a bad idea simply because OtherForm
is already loaded?

My point is this: The method you use to pass data to a form is not
determined by when the form is created.
Will I show you the threads where people have trouble with that.
When there is no reference to the object, the property in that is
unreachable and you can not pass.


Again, this is blatantly obvious.

But you don't have to know *when* the form is created, nor where the
form's reference is, before you can suggest methods of passing data to
the form.
Make sense?
-Dennis Borg
Nov 21 '05 #11
"Cor Ligthert" <no************@planet.nl> wrote in message news:<ep**************@TK2MSFTNGP11.phx.gbl>...
"Where" and "how" a form is created will simply determine where your
*reference* to that form is. However, that is a different issue. The
issue of when and where a form is created is "How do I reference a
form I've already created or am about to create?"


Yes therefore my question, from which you say that that is not needed.
This reference has more than one method depending on the is created form or
to create form.


I never said that the reference is not needed to pass data from one
form to another.

What I was saying is that how you get your form reference has no
effect on the method of choice for transferring data to that form.

In other words, I am going to use a form property or method to
transfer data to a form regardless of whether that form is already
loaded or not.

If the form is loaded at the start of the application, I'll use a
property or method to transfer the data. And if I am loading the form
at the same time as passing the data, I'll still use that same
property.

My method of passing the data from one form to another will not be
affected by when that form was created. It does not matter if it was
created long ago. It does not matter if I am creating it now. It does
not matter how I get my form reference. Regardless, I am still going
to use that property or that method to transfer the data to that form.

Does that make sense?
Nov 21 '05 #12
"Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> wrote in message news:<#f*************@TK2MSFTNGP12.phx.gbl>...
You must declare a Public variable, or else change the textbox declaration
to Public.


Gerry, I just thought I'd mention that I have not been trying to imply
that you were suggesting the use of an application global variable. As
far as I know, you may have meant a public variable of the form,
equivalent of a form property.
Nov 21 '05 #13
"Cor Ligthert" <no************@planet.nl> wrote in message news:<OK**************@TK2MSFTNGP10.phx.gbl>...
This question from you, gives forever a lot of messages.
Very important is where you create your "other" form and how you do that.


Cor, I understood you to be saying that the actual method of
transferring data to the other form would depend upon where that form
was created. Perhaps that is not what you were trying to say.

All I am saying is that regardless of how you obtain your form
reference, you would still transfer the data to the form in the same
way. If you were creating the form now, you would transfer the data
using the same method as you would if the form was created when the
application first started.

Hence my point: The how and when of when the form is created does not
affect the how of transferring the data to the form. You would use the
same method of transferring the data whether it's to an already loaded
form, or would to a form that is being loaded at this moment.
Nov 21 '05 #14
DenBorg,

Please see my other message

Cor
Nov 21 '05 #15
DenBorg,

I have not the idea that I have denied one word of what you wrote, except
that my addition in this thread is, that you first have to know where to get
the reference of the form.

That than the most advised method is for me obvious to use properties that
is for me not a part of a discussion. However a lot of people are in the
beginning still afraid of that, and than you start with a method that is
easier to learn, a kind of learning curve however mostly I write than that
better or advised is to use a property.

Cor
Nov 21 '05 #16

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

Similar topics

1
by: r_burgess | last post by:
I am looking for some guidance on transferring data between two pages in my ASP.net Web app (intranet). I have a form that will have a button and a text box on it (among other controls of course)...
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...
4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
3
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is...
3
by: phong.lee | last post by:
Hello all, i'm new at this. I need some assistant in transferring data from excel to access. I created a macro that basically gather all the necessary data that i need to bring into access. I...
3
by: Peter Newman | last post by:
i have used the data wizard form to create a data form with a datagrid on it. What i want to do is add a new coloum and put a Button in it. can anyboody showm me how to do this .... I will need...
2
hsriat
by: hsriat | last post by:
I have a page working on Ajax. The problem is, after doing many changes using Ajax (like uploading, changing name, adding to favorites etc), the status bar starts behaving unexpectedly. Even when...
3
by: angusfreefa | last post by:
Dear All, I am facing a problem of transferring data between 2 tables within the same database. I set up 2 tables. The first table is the permanent table (oos_table) for saving records. the...
35
computerfox
by: computerfox | last post by:
I'm writing a work order system using PHP and MySQL and I'm stuck on two things-transferring data and updating the data. Here is my code: i'm using checklogin.php to do most of everything so...
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: 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: 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: 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
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.