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 May 24th, 2006, 05:55 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing different projects in the same group

 I have two different projects forming one VB group. How can I access forms in Project 2 from Project1? And is it good programming practice to have more than one project in an application?

Thanks

 
Old May 24th, 2006, 03:58 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Question 2: is it good programming practice to have more than one project in an application?

- Yes. It is good programming practice to have more than one project in an application, so to speak. You do this all the time when you use ADODB in your project, for example. Without getting into the details, a well designed application can use dozens of DLLs that provide the services that application needs. Almost any sizeable app will do so, and countless articles have been written on the how and why of this.

Question 1: How can I access forms in Project 2 from Project1?
- Assuming project 2 is an activex dll, you could create a class (let's call it MyClass) that has its instancing property set to MultiUse. This class will have a public method on it that would look something like this:
Code:
Public Sub ShowMyForm()
    Dim f As MyForm
    Set f = New MyForm
    f.Show vbModal
End Sub
You would use code like this in project 1 in some sub or button click handler and you have a reference to Project 2 in Project 1):

Code:
Private Sub Command1_Click()
    Dim o As Project2.MyClass
    Set o = New Project2.MyClass
    o.ShowMyForm
End Sub
Or you could make this a function like this:

Code:
Public Function GetMyForm() As Object
    Set GetMyForm = New MyForm
End Function
And use it like this:

Code:
Private Sub Command2_Click()
    Dim o As Project2.MyClass
    Set o = New Project2.MyClass

    Dim f As Form
    Set f = o.GetMyForm
    f.Show vbModal
End Sub
These are just simplistic examples. You will have to work with this a bit to make it do whatever it is you actually need.



Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing previous item in current-group() in loop mikeymikey XSLT 1 January 4th, 2008 06:47 AM
Group Within another Group, xslt1.0 jhansib4u BOOK: XSLT Programmer's Reference, 2nd Edition 4 November 22nd, 2007 01:24 AM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Having problems with the Group Projects Panel Ch.9 Bo.B.B BOOK: Beginning VB.NET Databases 4 October 21st, 2005 05:27 PM
Group by , Sub Group by and Sum mateenmohd SQL Server 2000 1 March 29th, 2005 09:51 AM





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