Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 February 22nd, 2005, 07:11 PM
Registered User
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How To Create A Simple DLL with VB6

I'm trying to create a simple .dll for use with some of my more commonly used functions in VB. I have had a difficult time finding an example of code by searching the web. Does anyone have a simple-stupid example?

Old February 23rd, 2005, 01:36 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts

Don't know how much you need, but see if you can use any of this:


It's simple to use in VB. Make a new exe, add a class module, name it TC1 and add the class code to this. In the exe form, add a commandbutton and this code:

Private Sub Command1_Click()
Dim TC As TC1
Set TC = New TC1

TC.FirstName = "myFirstName"
TC.LastName = "andMyLastName"

MsgBox TC.BothNames
Set TC = Nothing
End Sub

..and from here, what you can do within the class, you'll have to have help from someone else. ;)
Old February 23rd, 2005, 04:23 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts

Open VB, select new Project and select ActiveX dll. Name the project (that will be the name of the library to reference to). The project comes already with a public class named Class1. Change that name to something more useful. Now, all the public methods and properties that you add in that class will be exposed by the library. Build it, then go to project properties, and in the Component tab select binary compatibility. This is extreme important. It means that after your library is built, you cannot remove public objects or methods, and you cannot change the definitions of public methods. You can indeed add new public classes and methods.

To test the library, File->Add Project and create a new exe project. Right click in the project explorer and select Set at start up. You can use your library from the new projects, and when you are debugging you can step in in every files.
This is just to give you a start. Full documentation in



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Reference to VB6 DLL webnet .NET Framework 2.0 3 October 4th, 2007 11:41 AM
Use .net dll in VB6? wakeup .NET Framework 2.0 3 March 8th, 2006 05:39 PM
Using .NET Dll from VB6 application Dmitriy Pro VB 6 5 January 30th, 2006 04:43 PM
VB6 DLL with Forms ................. Please Help tact_259 VB Components 0 November 16th, 2004 06:41 AM
Creation of ActiveX DLL with VB6 james gold Pro VB 6 2 September 10th, 2003 08:19 AM

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