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

References to references

I have 2 forms. In the first, I have a reference to an object. I want to
assign an object to that reference from within the second form. If I pass the
first reference to the new(...) method of the second form ByRef, I can easily
assign an object to the reference in the first form.

However, I don't want to make this assignment in the new(...) of the second
form. So I made a reference(of the same type) in the second form and assigned
it to the reference passed from the first form in the new(...) method. I
hoped that this way I could make an assignment to the reference in the second
form and change what the reference in the first form was pointing to, since
the references were assigned to each other in the new(...) method. Sort of a
reference to a reference. Unfortunately, it didn't work.

Is there a way in VB .NET to create a reference to a reference so that I can
delay the assignment of an object to a reference in another form to a method
other than the new(...)?

Michael
--
Michael Hockstein
--
Michael Hockstein
Nov 21 '05 #1
2 1180
You can create a shared variable in the main form the access it from Form2:
Like this

In Form1:

Public Class Form1
Inherits System.Windows.Forms.Form

'-- Shared
Public Shared myObject As YourClass
End Class
In Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Form1.myobject = New YourClass
End Sub


"michael" <ho**********@nospam.nospam> wrote in message
news:33**********************************@microsof t.com...
I have 2 forms. In the first, I have a reference to an object. I want to
assign an object to that reference from within the second form. If I pass
the
first reference to the new(...) method of the second form ByRef, I can
easily
assign an object to the reference in the first form.

However, I don't want to make this assignment in the new(...) of the
second
form. So I made a reference(of the same type) in the second form and
assigned
it to the reference passed from the first form in the new(...) method. I
hoped that this way I could make an assignment to the reference in the
second
form and change what the reference in the first form was pointing to,
since
the references were assigned to each other in the new(...) method. Sort of
a
reference to a reference. Unfortunately, it didn't work.

Is there a way in VB .NET to create a reference to a reference so that I
can
delay the assignment of an object to a reference in another form to a
method
other than the new(...)?

Michael
--
Michael Hockstein
--
Michael Hockstein

Nov 21 '05 #2
That'll work, but it's kind of like adding a global variable. I wanted to try
the reference route.

Thanks
"Think_Fast" wrote:
You can create a shared variable in the main form the access it from Form2:
Like this

In Form1:

Public Class Form1
Inherits System.Windows.Forms.Form

'-- Shared
Public Shared myObject As YourClass
End Class
In Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Form1.myobject = New YourClass
End Sub


"michael" <ho**********@nospam.nospam> wrote in message
news:33**********************************@microsof t.com...
I have 2 forms. In the first, I have a reference to an object. I want to
assign an object to that reference from within the second form. If I pass
the
first reference to the new(...) method of the second form ByRef, I can
easily
assign an object to the reference in the first form.

However, I don't want to make this assignment in the new(...) of the
second
form. So I made a reference(of the same type) in the second form and
assigned
it to the reference passed from the first form in the new(...) method. I
hoped that this way I could make an assignment to the reference in the
second
form and change what the reference in the first form was pointing to,
since
the references were assigned to each other in the new(...) method. Sort of
a
reference to a reference. Unfortunately, it didn't work.

Is there a way in VB .NET to create a reference to a reference so that I
can
delay the assignment of an object to a reference in another form to a
method
other than the new(...)?

Michael
--
Michael Hockstein
--
Michael Hockstein


Nov 21 '05 #3

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

Similar topics

22
by: xmp333 | last post by:
Hi All, I am trying to hide my JavaScript source. The method I chose was to keep all the important source in a password protected folder, and then use a SRC="folder/script.js" to include it...
2
by: S. van Beek | last post by:
Dear reader, For removing a reference in the VBA reference form I receive from Doug Steele the following code: ........... References.Remove refCurr
30
by: jeremygetsmail | last post by:
I've got an adp (Metrix.adp) with a reference to another adp (InteractSQL.adp). InteractSQL sits on a server, and is refered to by all of the clients (Metrix), which sit on the client machines...
3
by: DonJefe | last post by:
Does anyone have experience using project->project references in large solutions? What are the plus/minuses that you have found? Currently, we are using the binary assembly references for our...
9
by: igor.kulkin | last post by:
References is a relatively basic feature of C++ language. It might be a good thing to think of references as aliases to the variables. However it's good to think of references this way when you...
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
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
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,...

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.