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