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 April 20th, 2005, 04:10 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with opening and closing forms

Hello,
I have a problem which I have now been working on for the past day and a half, I have googled and seen previous posts (http://p2p.wrox.com/topic.asp?TOPIC_ID=28394), and yet I am still having trouble getting my head around it.
The problem is that on a click of a button I would like to OPEN a form called FORM2 and close a form called FORM1. I apologise if this post is trivial, its just that I've only recently started programming in VB.NET, and I would be greatful if anyone could shed some light or help me resolve my problem. Below is the code for opening FORM2 I will attempt to write the code for closing FORM1.

Code:
private Form2 as ReturnObject

Sub Button1_Click(sender As Object, e As EventArgs)
    Public Shadows Function ShowDialog() as ReturnObject
    MyBase.showDialog
    return Form2
End FUnction
End Sub
 
Old April 20th, 2005, 05:40 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can display a new form as follows

        Dim frmObj2 As Form2
        frmObj2 = New Form2
        frmObj2.Show()



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old April 20th, 2005, 06:27 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for getting back to me Pradeep, but I couldn't get it to work. I already have a FORM2 thats got dropdown lists and radio buttons.
I tried putting your code inside the Sub, but it just chucked out a compilation error.
Any more solutions, I'm open to any suggestions.
If someone could even give me sample code that would also be appreciated.

D

 
Old April 20th, 2005, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Your biggest problem is that if you set Form1 as the startup object, once you close it, your application ends. You also have a function within a sub, which is likely what is throwing your error.

To combat, the startup problem, you need to start your first form from a Sub Main() module. Here is a complete code example for this solution on this site:

http://www.experts-exchange.com/Prog..._21185658.html

J
 
Old April 21st, 2005, 03:19 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you J, thats exactly what I was after.

And Thank You Pradeep for your time.

D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening & Closing Database connections pauliehaha Classic ASP Databases 4 December 18th, 2006 08:50 AM
closing mdi child forms kanoorani VB Databases Basics 1 May 31st, 2006 03:08 PM
opening and closing forms mp VB.NET 2002/2003 Basics 6 April 2nd, 2005 07:37 PM
Closing and Opening Forms Louisa VB.NET 2002/2003 Basics 1 February 5th, 2004 02:40 PM





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