Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 18th, 2003, 10:35 PM
Registered User
 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to solva Send a message via Yahoo to solva
Default HELP!!!Coding a command button to open a form

How do you tell a command button to open a form?

I only know how to do it in VB6.0 and it does not seem to work the same in .NET

"I'm Still Learning" Neely Fuller Jr.
 
Old December 21st, 2003, 08:06 PM
Authorized User
 
Join Date: Oct 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Where do you want the command button? Do you want this on another form within the same project you are designing, or on a form on a different project? I presume you simply want a button to open a second form, within the same project.

Try this:

On Form1:

Public Class Form1
        Private WithEvents Form2 As Form

On your button_click event:

Form2 = New Form2()
        Form2.Show()


 
Old April 22nd, 2005, 01:12 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, this will work. But I've seen a problem that if you open more than one of reference forms, any subsequent form will not fire the event.

Example

Friend withevents _form1 as Form1

Private sub ClickAButton
_form1 = new Form1
_form1.show
end sub

In _form1, define your event (Public Event UpdateTheGrid), then raise the event when closing the form. (RaiseEvent UpdateTheGrid).

I have not been able to get the event listener to fire on the second, third, forth, etc.. instance of the form

 
Old May 9th, 2005, 10:03 PM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am just beginning to look at Visual Basic code and have I know will be seen as a small, stupid question but I am stuck on this one point.

I am trying to make a command button on Form1 inside my new project to automatically open Form2 inside the same project. I am using VB6.0. I basically just want the opening form to have 6 command buttons on it that each open a different form (form2-form7).

Can any one help me figure out how to make this happen? Code is appreciated... thanks

 
Old May 10th, 2005, 04:16 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Solva and ebush,
If you look at this post near the bottom is a link posted by katsarosj,
I believe this is what you both are after.

http://p2p.wrox.com/topic.asp?TOPIC_ID=29494

 
Old May 10th, 2005, 09:56 PM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help and link. I have another question I know was brought up before but the answer that is given really does not make sense to my beginner eyes.

Now that I have found out how to get a command button to open another form I now need some specific code that will allow me to have each form close when the command button is clicked to open another form. Basically I just do not want to have the user keep opening forms and the forms not closing on their own. (build up issue)

If some one could provide me code it would be much appreciated, and if the code is supplied if you could provide it to me starting at the "Private" statement would really help as I am able to better learn where the code is going this way. Thanks again.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Form does not open when commandbar button clicked Arsi BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 21 March 5th, 2009 04:03 AM
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
how to open a new VB 2005 form from a button? asimzeeshan Visual Basic 2005 Basics 4 August 20th, 2006 11:25 AM
coding for "update" button.. ct Excel VBA 4 August 12th, 2005 02:55 AM
Need to open a PDF with a command button RayL Access VBA 2 January 27th, 2004 12:53 PM





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