Creating Classes & ActiveX Controls

Creating a control

When creating a new class you have a number of options:

1) Create a new ActiveX Control project, and add controls to that. This will then be compiled into a OCX, which can then be used by multiple projects.

2) Just add a new control to your current EXE project. This will be included into your EXE, and cannot be used by other projects.

To create a new ActiveX Control project:

1) Select File|Add Project, and double click on ActiveX Control. A new project is added to your project group.

2) A control is automatically added to the ActiveX control project for you.

3) Give the project a suitable name

To add a new class to your current EXE project:

1) Select Project|Add User Control, and double click on User Control.

2) A new control is added to your project.

Then give the class a good name that means something:

f123x - not a good name. What's it for? Is it a class, control, form or a module?

Project - getting there. This control displays a project. Is it a class, control, form or a module?

ctlProject - good! This is a control (ctl) that displays a project, and will have methods and properties to allow you to use it.

A new icon on the toolbox has been added. Select your EXE project and add the control to a form. If the new icon is disabled, close both the form window and the code window of your Control. When you switch back to the EXE project, the icon will have been enabled.

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter” - Eric Raymond