473,466 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Working between forms


Hello I have two forms which have components on them. On Screen1 I have
a component which I want to update from Screen2. However, if I simply
call the component from Screen2 it can't find it. If I create a new
instance of Screen1 in Screen2 and then call the component using a
reference, this works, but I end up with 2 Screen1's and the original
screen is not updated since I am only updating the new instance of
Screen1. How do I make the component available to Screen2? I changed the
components access property to Public but this didn't seem to make any
difference. Or can I stop the initial form from loading?

I tried to add a Main module:

Module Startup
Public scr1 As Screen1
Public scr2 As Screen2

Sub Main()
scr1 = New Screen1
scr2 = New Screen2
scr1.Activate()
scr1.Show()
End Sub
End Module

But this just partially loads the form then bombs out with no errors or
anything.

Cheers


--
Jeffrey Spoon

Nov 21 '05 #1
5 991
Jeffrey Spoon wrote:

Hello I have two forms which have components on them. On Screen1 I have
a component which I want to update from Screen2. However, if I simply
call the component from Screen2 it can't find it. If I create a new
instance of Screen1 in Screen2 and then call the component using a
reference, this works, but I end up with 2 Screen1's and the original
screen is not updated since I am only updating the new instance of
Screen1. How do I make the component available to Screen2? I changed the
components access property to Public but this didn't seem to make any
difference. Or can I stop the initial form from loading?

I tried to add a Main module:

Module Startup
Public scr1 As Screen1
Public scr2 As Screen2

Sub Main()
scr1 = New Screen1
scr2 = New Screen2
scr1.Activate()
scr1.Show()
End Sub
End Module

But this just partially loads the form then bombs out with no errors or
anything.

Cheers


You need to pass Screen2 the instance of Screen1 so that S2 knows where
S1 is.

Example:

Class S2
Dim ptrS1 as S1
Sub New(Value as S1)
ptrS1 = Value
End Sub
End Class

Sub Main()
scr1 = New Screen1
scr2 = New Screen2(scr1)
End Sub

Now you will be able to act on S1 in S2.

Chris
Nov 21 '05 #2
In message <e8*************@TK2MSFTNGP12.phx.gbl>, Chris <no@spam.com>
writes

You need to pass Screen2 the instance of Screen1 so that S2 knows where
S1 is.

Example:

Class S2
Dim ptrS1 as S1
Sub New(Value as S1)
ptrS1 = Value
End Sub
End Class

Sub Main()
scr1 = New Screen1
scr2 = New Screen2(scr1)
End Sub

Now you will be able to act on S1 in S2.

Chris


Thanks Chris. I still can't seem to load Screen1 properly though from
Main. The window loads and vanishes. Originally when I was loading it
straight from Screen1 it worked ok, using a form load event handler.
--
Jeffrey Spoon

Nov 21 '05 #3
Jeffrey Spoon wrote:
In message <e8*************@TK2MSFTNGP12.phx.gbl>, Chris <no@spam.com>
writes

You need to pass Screen2 the instance of Screen1 so that S2 knows
where S1 is.

Example:

Class S2
Dim ptrS1 as S1
Sub New(Value as S1)
ptrS1 = Value
End Sub
End Class

Sub Main()
scr1 = New Screen1
scr2 = New Screen2(scr1)
End Sub

Now you will be able to act on S1 in S2.

Chris

Thanks Chris. I still can't seem to load Screen1 properly though from
Main. The window loads and vanishes. Originally when I was loading it
straight from Screen1 it worked ok, using a form load event handler.

This is because all your threads have exited. You don't have any
message loops setup. That is just a fancy way of saying you need to use
ShowDialog (a blocking call so your thread won't exit until the form is
closed) instead of Show.

Chris
Nov 21 '05 #4
In message <Od**************@tk2msftngp13.phx.gbl>, Chris <no@spam.com>
writes

This is because all your threads have exited. You don't have any
message loops setup. That is just a fancy way of saying you need to
use ShowDialog (a blocking call so your thread won't exit until the
form is closed) instead of Show.

Chris


Excellent thanks. That worked, although Screen2's components are
complaining of a null reference. I would've thought that it would use
the reference in Main? Anyway I'll work on it. Cheers.
--
Jeffrey Spoon

Nov 21 '05 #5
In message <J+**************@nowhere.nnn>, Jeffrey Spoon
<Je**********@hotmail.com> writes
In message <Od**************@tk2msftngp13.phx.gbl>, Chris <no@spam.com>
writes

This is because all your threads have exited. You don't have any
message loops setup. That is just a fancy way of saying you need to
use ShowDialog (a blocking call so your thread won't exit until the
form is closed) instead of Show.

Chris


Excellent thanks. That worked, although Screen2's components are
complaining of a null reference. I would've thought that it would use
the reference in Main? Anyway I'll work on it. Cheers.


Finally I have it working. Of course it was something stupidly simple
(didn't reference the module properly - doh!)

Cheers Chris.

--
Jeffrey Spoon

Nov 21 '05 #6

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

Similar topics

7
by: Mikael Östberg | last post by:
Hello all! I have been working on a project for some time now and yesterday, my debugger stopped working. It is a class library which I run from a Win32 test app, so no IIS involved at this...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
5
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the...
5
by: Jeff Johnson | last post by:
I'm using forms authentication to protect a subfolder within my site. I've got it working fine except for two issues: (1) When I do a RedirectFromLogin page I have to put a cookie path ("/"...
6
by: Gary | last post by:
Hi, I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)") This is not working ..what could be the...
36
by: AussieRules | last post by:
Hi, I want to use the user color scheme to set the color of my forms. I now I have to use the. System.Drawing.SystemColors, but which color is the color of a form background as used in other...
1
by: harinathch | last post by:
Hi, Iam working with myapplication.exe.config file in my vb.net windows application.Its working fine in my development environment. When i test this application in some other machine using exe and...
4
by: Michael | last post by:
Hi Everyone, I'm hoping someone out there can give me some guidance. I'm currenlty using VS2005 and the other day the Form Wizzard stopped working. What I mean, is that the wizzard no longer...
0
jas16183
by: jas16183 | last post by:
Hi Guys, need some help here, Im working on a project in vb.net, the problem im facing is that my tableadapter.update(dataset.datatable) is not functioning, the datatable has a relation with...
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,...
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...
0
agi2029
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.