Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2003, 12:23 PM
Registered User
 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Do I Close a Form When I Move to Another Form.

I just started on VB.Net for a weeks now, and I recently have been encountering a problem with closing form1 when I try to switch over to form2 on my window application. I want to close form1 complettely when form2 comes up. How do I go about doing this.

This is the code that I have:
I instantiate an instance of the form2 with form1 by doing this on form1 btnEnter_Click Handler.

Dim myform As Form2
myform = New Form2()

'I have a textbox with which I have a pass word validation...

Dim n As String
Try
txtValue.Text
Catch
End Try

If n = "123" Then
myForm.Show()
Else
MessageBox.Show("invalid Password","")
End If

When I Cancel out Form1, Form2 wound Disappear also...

A Beginner needs your help!
Thank You very Much

 
Old December 27th, 2003, 09:17 PM
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you are instantiating form2 from within form1. Therefore, when Form1 is closed, Form2 goes out of scope and is also closed. You could try declaring form2 in the sub main() and starting form1 from there. Then, from within form1, you can show form2(do not use showdialog of course). Afterwards, you should be able to close form1 without form2 also closing.

Hope this makes sense!
Good luck!

 
Old December 27th, 2003, 09:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Is there a reason that you can't just hide the form using:

Me.Hide()

and showing the other form?

J
 
Old December 29th, 2003, 08:56 AM
Authorized User
 
Join Date: Jun 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, thanks.

Renee C. Walker





Similar Threads
Thread Thread Starter Forum Replies Last Post
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
Close all MdiChield form from open one form salman .NET Framework 1.x 0 November 8th, 2007 12:32 AM
How to Move Multiple Control on a form at runtime? sivavenugopal VB How-To 1 January 22nd, 2007 01:49 PM
How To Close One Form And Show Another form Israr VS.NET 2002/2003 1 December 7th, 2004 12:30 PM
Move the form ?? simsimlhr C# 1 April 1st, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.