Wrox Programmer Forums
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases 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 September 6th, 2004, 06:03 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default re-usability

Hi

I have a number of applications that all need to have the same (complex) screen handling. E.g. every field on every screen has a set of parameters held on a jet database and these define for example if only a date in the future can be entered into the field.

The application is now up and running but I am not happy that I have organised the code well

Each application has its own forms, but all of the event handlers call routines that are stored in 'common' modules that I have added to each application's project. I thus have many projects, but only one set of common modules

The problem is that every time I make a change to a common module, I have to re-create an .exe file for each application and as the number grows this is tedious.

Is there a better way to organise the code?

Is there a way of creating .exe files from a script?

Thanks for reading :)

Thanks
Psionman
__________________
Thanks
Psionman
 
Old September 6th, 2004, 07:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Depending on what your common code does, it may be possible to put it in one or more DLLs instead and reference them in each EXE. Then you wouldn't need to re-compile the EXEs at all.

Failing that, I can think of a couple of ways to compile a whole bunch of EXEs:
1. put them all in VB Group, then just make the group
2. write some script to invoke VB6.exe from the command-line with the "/make" option, passing it the relevant project file names

hth
Phil
 
Old September 6th, 2004, 07:41 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Phil

Some of the common code does things like setfocus to a textbox, or update the value of a textbox on a form. I'm new to this but can this be done from dlls?

Thanks
Psionman
 
Old September 6th, 2004, 09:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

A textbox is just an object that can be passed around like any other object. Just declare a parameter of type TextBox...
 
Old September 6th, 2004, 10:52 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again Phil

I am using the Project Group idea and it works perfectly for me - you live & learn

As to the DLL issue. I have simplified each form by making all of the textboxes an object array and the only code on the form is is of the type

Private Sub txtInput_Change(Index As Integer)
    Call modForm.txtInput_Change(Me, Index)
End Sub

But in the dll, when I put the proc:

Sub txtInput_Change(myForm As Form, Index As Integer)
    'Blah Blah Blah
End Sub

I get an error 'Private object modules cannot be used in public object modules ... '

Aren't I just passing the form around like any other object?

Thanks
Psionman
 
Old September 7th, 2004, 07:11 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK! I think I've cracked it

You need some code like



Public Function NewTime(frmTemp As Variant, Index As Integer)
    Dim myForm As Form
    Set myForm = frmTemp
    myForm.txtinput(Index).SetFocus
End Function

This works!

Thanks for your help

Thanks
Psionman





Similar Threads
Thread Thread Starter Forum Replies Last Post
Integrated Development Environment (IDE) Usability rbkline VB How-To 0 September 14th, 2004 08:28 AM
Integrated Development Environment (IDE) Usability rbkline Visual C++ 0 September 14th, 2004 08:25 AM
usability pb7 Forum and Wrox.com Feedback 4 June 18th, 2003 07:11 AM





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