Hello,
I am trying to reference an object that already exists,
ie, I have a dll project (dllProj) which contains a simple
form. Then I have a main app and a secondary app which
both have references to dllProj. When I start the
project, the main app starts up. I then invoke the
dllProj from the main app and pass data to a property in
dllProj (PropertyOne) which then displays in a textbox on
dllProj. I can set data to another property in dllProj
(NameProperty) and then I can read NameProperty in the
main app. Then the main app starts up a secondary app
(form). I would like to read the value of NameProperty in
dllProj from the secondary app. I tried the following in
the secondary app but got an error:
Dim frm As dllProj.dllForm Class
Private Sub Form_Load(...)
Dim s As String
s = frm.NamePropert y
msgbox s
End Sub
I get the error that the object frm was not set to an
instance of dllProj.dllForm Class. In the main app I say
Dim frm New dllProj.dllForm Class
Dim s As String
s = frm.NamProperty
This works fine except it is a new instance. I would like
to access the existing content of NameProperty contained
in dllProj from the secondary app. So, in addition to
having a reference to dllProj in the secondary app I also
tried
Imports dllProjNamespac e
this did not help either. Is there a way I can reference
the already existing instance of dllProj from my secondary
app? Do I need to use something like GetObject?
Thanks,
Rich 2 1537
You must pass an instance of your existing form (or object), into the
new form (or object).
One way to do this would be to overload the constructor of the second
class to take the argument. For example (watch for typos):
'Button click in Form1 creates Form2 and passes ref to Form1
Public Sub Button1_Click(. ..) handles button1.click
Dim frm As New Form2(Me) 'Note that I'm passing in Me
frm.ShowDialog( )
End Sub
'Now in Form2, we overload the constructor:
Public Sub New(frm As Form1)
'Do something with frm here
frm.NamePropert y = "whatever"
End Sub
There are other ways, but this is a simple way.
Thanks. Actually, the 2nd form is a second application.
I invoke it with System.Diagnost ics.Process.Sta rt
(shelling to it). So it is not part of the original
application, although, it IS part of the project, 3
projects in one. The original application, the dll
application, and the 2nd application. I already tried the
constructor idea, but Process.Start will only pass a
string argument and not an object. Thus, I was thinking
about some form of GetObject. -----Original Message----- You must pass an instance of your existing form (or
object), into thenew form (or object).
One way to do this would be to overload the constructor
of the secondclass to take the argument. For example (watch for
typos): 'Button click in Form1 creates Form2 and passes ref to
Form1Public Sub Button1_Click(. ..) handles button1.click Dim frm As New Form2(Me) 'Note that I'm passing in Me frm.ShowDialog () End Sub
'Now in Form2, we overload the constructor: Public Sub New(frm As Form1) 'Do something with frm here frm.NameProper ty = "whatever" End Sub
There are other ways, but this is a simple way.
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andy C |
last post by:
I am new to python, so please bear with me if I am making some
conceptual error.
Basically I want to create a graph with an adjacency list
representation, but I don't want any of the adjacency lists to have
duplicate strings when it is avoidable. I have a function createEdge
that adds an edge to the graph. The arguments will be distinct since
they are read from text files. But basically I want to use the
dictionary as a string pool,...
|
by: mjm |
last post by:
Folks,
Stroustrup indicates that returning by value can be faster than
returning by reference but gives no details as to the size of the
returned object up to which this holds.
My question is up to which size m would you expect
vector<double> returns_by_value()
{
|
by: Pablo J Royo |
last post by:
Hello:
i have a function that reads a file as an argument and returns a reference
to an object that contains some information obtained from the file: FData
&ReadFile(string FilePath);
But , for example, when the file doesnt exists, i should not return any
reference to a bad constructed object, so i need something as a NULL
reference object. I suppose i could return a pointer instead, but i have
some code written with references which...
|
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object must be an object
instead of
|
by: mabuHB |
last post by:
Hi,
I am writing a small app to check for the existence of files on remote
workstations. GUI is great, but when I click to check the workstations, the
following error is displayed. The point of failure is highlighted within the
code sample. I beleive the problem is to do with the arraylist within the
structure, but have no proof or idea of how to fix the problem. I have tried
changing the structure into classes, writing a text string...
| |
by: Brad Pears |
last post by:
I want to check to see if a particular object exists using vb.net 2005.
I have a class called clsContract. When the user clicks the 'New Contract'
button, I want to check to see if a clsContract object already exists and if
so what the state of that object is before doing anything else.
I thought I could use ...
if IsNothing(clsContract) then
'somc code
|
by: John Sheppard |
last post by:
Hello there I was wondering if anyone could help me,
I am trying to pass a typed dataset to a dialoged child form by reference.
I have binding sources sitting on the child form. So to refresh them I just
set their datasource. I am guessing this is probably what is causing the
problem. Is there a better way to do this?
Anyway this all works happily and things show up when the record already
exists but I have 2 problems ;
1) When I add...
|
by: Ray Cassick |
last post by:
I can't believe why I had not noticed this before and why I never asked it
before...
When defining a string why is it not required to use the new keyword? Like:
Dim a As String = New String
You can do it when using the string type with some arguments in the
constructor but it look like there is no empty constructor on the String
class.
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |