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

how to open one form from the other form and close the first form

how to open one form from the other form and close the first form if
there are only two forms in windows application(VB.net)
i had tried this method
dim f as new form2
form2.show( )
me.close( )

But, when i run this application both the forms are closing at the
same time
Nov 15 '07 #1
3 2452
On 2007-11-14 22:18:13 -0800, "ra***************@gmail.com"
<ra***************@gmail.comsaid:
how to open one form from the other form and close the first form if
there are only two forms in windows application(VB.net)

i had tried this method
dim f as new form2
form2.show( )
me.close( )

But, when i run this application both the forms are closing at the
same time
This is a C# newsgroup. If you have questions that don't involve
writing C# code, you should post them elsewhere.

That said, the basic structure of what you posted should work fine, not
counting what appears to be a typographical error in your post.
Calling "f.Show()" should show the second form, and that form should
not close just because you close the current form.

In C# it would look something like this:

class Form1 : Form
{
void SomeMethod()
{
Form2 form = new Form2();

form.Show();
Close();
}
}

And that should work fine.

If you can post C# code that concisely but completely demonstrates the
problem you're having, please feel free to follow up here with that
sample. If you require VB code, then you should post to a VB or
general-purpose .NET programming newsgroup. There still you will want
to post a concise-but-complete sample of code that demonstrates the
problem. The basic idea works fine as you describe so if you're having
trouble getting it to work, you're doing something else that's not
immediately apparent.

Pete

Nov 15 '07 #2

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:2007111415371375249-NpOeStPeAdM@NnOwSlPiAnMkcom...
On 2007-11-14 22:18:13 -0800, "ra***************@gmail.com"
<ra***************@gmail.comsaid:
>how to open one form from the other form and close the first form if
there are only two forms in windows application(VB.net)

i had tried this method
dim f as new form2
form2.show( )
me.close( )

But, when i run this application both the forms are closing at the
same time

This is a C# newsgroup. If you have questions that don't involve writing
C# code, you should post them elsewhere.

That said, the basic structure of what you posted should work fine, not
counting what appears to be a typographical error in your post. Calling
"f.Show()" should show the second form, and that form should not close
just because you close the current form.

In C# it would look something like this:

class Form1 : Form
{
void SomeMethod()
{
Form2 form = new Form2();

form.Show();
Close();
}
}

And that should work fine.
If you have passed a Form instance to Application.Run, the application will
end when that Form closes...

One solution is to use the arg-less version of Application.Run and count
visible forms (ala reference counting).
Nov 15 '07 #3
On 2007-11-15 14:04:21 -0800, "Ben Voigt [C++ MVP]" <rb*@nospam.nospamsaid:
If you have passed a Form instance to Application.Run, the application will
end when that Form closes...
Yup, that's true. The OP never mentioned his application was actually
exiting (seems like that'd be a significant point), so it didn't occur
to me he might be dealing with that situation. But that's probably
just a poorly-formed question...your guess is likely right.

Just goes to show the value of a concise-but-complete sample of code.
:) It's a lot easier to know the specifics when you can see the code.
One solution is to use the arg-less version of Application.Run and count
visible forms (ala reference counting).
The Application.OpenForms property would be a useful source for this
information (as opposed to adding some specific count of forms in a
static variable for example).

Pete

Nov 15 '07 #4

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

Similar topics

4
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I...
1
by: petersk | last post by:
Firstly I am an older person trying to teach myself to create a project and teach myself Access VBA programming along the way. I anticipate a number of problems I will need help with but here...
3
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want...
3
by: Ronald S. Cook | last post by:
I know how to close and open a form... Well.. but can you tell me how can I do this..... Example... There are 2 forms...named formA and formB and each of them have their own button named...
13
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the...
3
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
2
by: RP | last post by:
I have a login form. I want to open the main MDI form if the login was successful and want to close the login form. I tried below code, but it is not working:...
25
by: Andy_Khosravi | last post by:
I just recently changed my database that I'm running from a monolithic DB to a split FE/BE. The front end resides on the client machine and the BE resides on a network drive. I'm experimenting with...
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
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
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...
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.