Fog Creek Software
Discussion Board




Having VB 3 program call VB program or DLL?

Hi,

Ok, after you stop laughing, read on :-)

Any easy way to have an old VB 3 program call a new VB 6 program (or DLL created from VB 6)?

I'm thinking maybe a straight DLL call or perhaps (ugghhh!) OLE.



I want to move some cranky code from the VB 3 app (recording sound) to a VB 6 app.  The VB 3 app needs to call the recording feature then wait for it to finish and continue on.

Entrepreneur
Tuesday, July 08, 2003

If the VB3 program has a hard time calling the new VB6 add-on, you could try writing a VB-callable DLL in PowerBasic:

http://www.powerbasic.com

Originally, PB was marketed as a tool to do just this : Write DLLs for VB applications.

Frederic Faure
Tuesday, July 08, 2003

Entrepreneur,

Does VB3 support DDE?

http://www.angelfire.com/biz/rhaminisys/ddeapps.html#DDEAppsTop

Ged Byrne
Tuesday, July 08, 2003

I'd port the VB3.

There's no way to create a standard .dll in VB6 (at least not without some very serious hacking).

It's dead easy to make a COM / ActiveX .dll in VB6 however, and VB3 could access it as a scripting client --- although this is a less than ideal approach from a performance point of view.  See:
http://archive.devx.com/premier/mgznarch/vbpj/1996/05may96/pclass.pdf

You could also probably make an ActiveX control in VB6 and access it through the OLE2.0 container control in VB3.

Finally you could make a separate VB6 exe and try to talk to it via some of the more traditional approaches (eg. the SendMsg API), but this would be pretty oddball and not recommended.

John Aitken
Tuesday, July 08, 2003

Isn't VB 3 still the 16-bit version? There's no way you'll be able to easily get it to call a 32-bit DLL or COM object without a lot more low level grunge (remember the thunk compiler, anyone?) than you really want to deal with.

Port the whole app to VB 6 (or VB.NET for that matter). Your life will be a whole lot better.

Chris Tavares
Wednesday, July 09, 2003

Chris,

The options are:
1.  Write 50 lines of code in VB 6 and figure a way to communicate.

2. Write 10,000 lines of VB 6 code.


So, there's a bit of incentive to figure a way to do option #1.

Entrepreneur
Wednesday, July 09, 2003

Entrepreneur,
Check out the article at archive.devx referenced by John Aitken earlier in this topic. The article discusses calling a VB4 object from VB3, but calling a VB6 object from VB3 works just the same. Also, the article talks about an "OLE Server" - the names changed several times over the years and this is now a COM component (or ActiveX DLL).

Using VB6, create an ActiveX DLL, and then in your VB3 code, you can use CreateObject to create an instance of the DLL and then call methods in the VB6 DLL. The VB3 code will wait until the return from the VB6 DLL method.

Philip Dickerson
Wednesday, July 09, 2003

*  Recent Topics

*  Fog Creek Home