473,406 Members | 2,217 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,406 software developers and data experts.

Show hidden form1

Hello there,

I have a form that is called from a Sub Main procedure using
application.run(Form1).

On my main form there is a button to open an instance of Form2 and
then at the same time hide Form1.

So far so good.

What I would like to then do is to have a close button on Form2 which
closes Form2 (not a problem) but then re-shows the hidden form1 (or at
least the instance of the hidden form1).

Can anyone show me how to achieve this?

Thank you very much.

Richard

Nov 21 '05 #1
1 1893
There are a ton of methods of referencing a form from another form. This is
probably one of the most common questions asked on these boards. Here's one
solution:

Create a Module and declare a variable of type Form1 and one of type Form2.
When the application starts, assign your start-up form to the Form1 variable
in the Module. Also instantiate (but hide) an instance of Form2 and assign
it to the Form2 variable in your module.
Now whenever you want Form1 to be shown, just hide Form2 and un-hide Form1
via the variables in the Module.

I.e.,

' From the Module
Dim f1 As Form1
Dim f2 As Form2

' In your form1 Load method
f1 = Me
f2 = New (Form2)

' When you want to show form1 and hide form2
f1.Visible = true
f2.Visible = false
f1.Activate()

' When you want to show form1 and hide form2
f2.Visible = true
f1.Visible = false
f2.Activate()

You'll need to cancel the Close event for each form or have some other
mechanism to tell when a form has been closed and needs to be re-created.

"Richard" <xx******************@yahoo.co.uk> wrote in message
news:p9********************************@4ax.com...
Hello there,

I have a form that is called from a Sub Main procedure using
application.run(Form1).

On my main form there is a button to open an instance of Form2 and
then at the same time hide Form1.

So far so good.

What I would like to then do is to have a close button on Form2 which
closes Form2 (not a problem) but then re-shows the hidden form1 (or at
least the instance of the hidden form1).

Can anyone show me how to achieve this?

Thank you very much.

Richard

Nov 21 '05 #2

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

Similar topics

7
by: Mad Scientist Jr | last post by:
Through messing around I got IE6 (win xp) to show/hide a table row. I gave my <TR> an ID of "trRow" and trRow.style.display='none'; hides it trRow.style.display='block'; displays it (will any...
13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
3
by: Roy Adams | last post by:
Hi I'm reposting this question because for some reason can't post follow up question to this thread. What I'm trying to do is put the value and text from a a select in to a text field and to a...
3
by: veganeater | last post by:
Hi, I'm wondering if there's a way that I can select which <div> to show based on the user's selection from a dropdown/listbox form. <form name="form1" method="post" action=""> <select...
5
by: Susan | last post by:
I have an application. When a user minimizes it it hides itselfs but stays activate in the system tray. Since it is hidden the user may think that they have exited the application and now may...
2
by: John Holmes | last post by:
I would like to turn on a label control in javascript with the onfocus event of another control by setting the Visible property to true. When I try and reference this label control it says...
2
by: Hareth | last post by:
VS2003 if i say dim form1 as new form1 form1.show() It opens a new form everytime... But....what if....
17
by: Jim Burns | last post by:
How do I Get a ref to my hidden Object like a Form1 When I try to Show the Form1 from Form2 I can not get a reference to the same instance. I can Show New Form1's but I cant unhide The one I Hid...
3
by: alcapoontje | last post by:
i'm making somekind of pad with commandbuttons and different forms. -> when you click the cmd on form1, form1 is hidden and form 2 is showed when you click the cmd on form2, form2 is hidden and...
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
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
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
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
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
isladogs
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...

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.