Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 May 24th, 2006, 05:55 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old May 24th, 2006, 03:58 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
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
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
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



All times are GMT -4. The time now is 01:57 PM.


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