Wrox Programmer Forums
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials 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 August 11th, 2009, 04:51 AM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with VB forms

Hi everyone!

I'm newbie in Visual Basic.
I have a question that refers to basics of windows programming.
I have 2 forms, and i know how to load each and close each, but i don't know how to close second form with first one.
I have tried with this code:

Dim myform1 as New Form2
myform1.Close()

But this code closes only new created form, and old (parent) form remains active.

If i try without New, complete program crashes!
So if you know something, please help me.
TNX
 
Old August 11th, 2009, 08:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

There are several ways to do this.

Easy one, is to have a variable that points to each form, and then close the form from there.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old August 11th, 2009, 08:55 AM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You mean to use a pointer ...
I know how to do it in C or C++ but i never saw something like that in VB. Is there any site with some code examples?

Maybe there is another way, something with classes (forms) themselves.
Can I change "private" property of form to "public", so i can access it from another form without any referencing?
 
Old August 11th, 2009, 09:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

No.. not a pointer..

This is easier (is an easier language)... For the sake of brebety, just define a public variable on a public module, when you dim your form, use that variable to hold the form.. and then you can access it for everywhere....
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting forms from VBA to VB.net Kapil General .NET 0 February 9th, 2007 01:30 AM
Using VB.net In Access Forms ahali Access VBA 4 February 23rd, 2006 08:26 AM
New at VB.Net - Need help with delpoying web forms Pail .NET Web Services 0 September 21st, 2005 02:22 PM
Printing Forms in VB.NET? gisenberg VB.NET 2002/2003 Basics 0 July 23rd, 2004 08:22 PM
Rounded VB forms??? Lost_Found VB How-To 4 June 26th, 2004 01:05 AM





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