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 March 24th, 2005, 09:45 AM
mp mp is offline
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default opening and closing forms

I realize this is very basic, but somehow I am not quite getting it.
I want to close the main form (aka form1) and have only form2 showing.
To open my existing, designed form2 from form1, I do this under a button click event on form1:

dim newform2 as form 'I've tried *as form2* and it doesn't work either
        newform2 = new form2
        newform2.show()

Ok, form2 now shows up. Then under a button click event I do this:

Dim newform1 As Form 'I've tried *as form1* and it doesn't work either
        newform1 = New Form1
        newform1.Close()

To close form1. But alas, nothing happens. Form2 stays just as proud as it can be. What am I missing here. Can you believe I just finished writing an involved application that works well, but I still don't get this?

Mike

Reply With Quote
  #2 (permalink)  
Old March 24th, 2005, 11:56 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You are creating a new instance of form 1, then closing that new instance.

You need to close the existing instance of it. You should be able to reference the existing instance of form1 without creating any new objects through which to reference it.
Reply With Quote
  #3 (permalink)  
Old March 24th, 2005, 02:29 PM
mp mp is offline
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

me.close() executed from form2 closes both form1 and form2 simultaneously.

Mike
Reply With Quote
  #4 (permalink)  
Old March 24th, 2005, 03:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Is this what you want? Me.Close should only close both forms if, in your case, Form2 is set as the startup form.

J
Reply With Quote
  #5 (permalink)  
Old March 24th, 2005, 03:56 PM
mp mp is offline
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now we are getting somewhere. I simplified my problem for purposes of this forum. The actual program has 6 forms. Form6 is the splash form. I'm fading out form6 into my form1 which is the main form. So I am calling timer events to gradually, but quickly, decrease opacity. When it is done transitioning, I dispose of the timer and I want to make the startup form, which I assigned as form6, to hide, which I can do, and then be closed out of memory. Me.close() in its many variations of what I have been trying has closed both form6 and form 1. So I tried closing form 6 after form1 has received focus, but I can't seem to do that either. I'm confused. Any help is greatly appreciated. Thanks,

Mike

Reply With Quote
  #6 (permalink)  
Old March 24th, 2005, 05:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Here is one way of setting a startup form and then I'll tell you what I think might be a better solution for what you want(I already typed all of this so I thought I would throw it in as well).

Create a new module in your project, name it whatever you want, but you need to include within it a "Sub Main()". Within this Sub Main you can instantiate whatever form you want without having an owner window. An example of something like this is Macromedia Fireworks MX where they display only the splash page, finish initializing, then show the main form.

Dim frm as New Form1
frm.ShowDialog()

'note the use of showdialog - display your tooltip from your intellisense to get a description
'if you use Show(), it will briefly display your form and then close it after the Sub() is finished running (usually about 1 second).

Then, in your project properties, set your startup object to "Sub Main".

----------------------------------------

Now for what I think might be more of what you want.

When your Form1 starts up, set Form 6 as a modal dialog box, run its timer event and then close it. Form 1 should still be open.

Either way, hopefully one of the suggestions helps.

J
Reply With Quote
  #7 (permalink)  
Old April 2nd, 2005, 07:37 PM
mp mp is offline
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply. I tried it both your suggested ways and it became clear to me that I can't do what I am trying to do which is to have one form under another form and the dissolution of the top form reveals the underlying form and the top form be able to closed out of memory. I was able to do it where it would stay in memory, but not close out. I think what needs to be done requires two threads. So for now, I have to be satisfied with the dissolution of one and the immediate startup of another. That is, until I figure out threads.



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
Help with opening and closing forms Dwizz VB.NET 2002/2003 Basics 4 April 21st, 2005 03:19 AM
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 03:39 PM.


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