Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 20th, 2005, 04:10 AM
Authorized User
 
Join Date: Apr 2005
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old April 20th, 2005, 05:40 AM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
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
Reply With Quote
  #3 (permalink)  
Old April 20th, 2005, 06:27 AM
Authorized User
 
Join Date: Apr 2005
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old April 20th, 2005, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #5 (permalink)  
Old April 21st, 2005, 03:19 AM
Authorized User
 
Join Date: Apr 2005
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:49 AM.


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