Make Your Own Control - Part 2
Well, as last time, load Visual Basic and choose "ActiveX Control" from the New Project dialog. Open up the code window for the control and go to the General Declarations procedure. Add this code which declares your name and web site address as a string:
Private mvarauthor As String Private mvarURL As String
Now add these four pieces of code which store and retrieve the settings:
Public Property Let URL(ByVal vData As String) mvarURL = vData End Property Public Property Get URL() As String URL = mvarURL End Property Public Property Let author(ByVal vData As String) mvarauthor = vData End Property Public Property Get author() As String author = mvarauthor End Property
Now add two labels to the control, and change the caption properties on each one to your name and web site address. e.g.
Lblname.caption="Sam Huggill" LblURL.caption="http://www.vbsquare.com/"
Almost finished. Open the code window for the control and go to the controls Initialise procedure and add this code:
Private Sub UserControl_Initialize() Me.author = lblName.Caption Me.URL = lblURL.Caption End Sub
Now click File, Make Project1.ocx. Select a directory for the file. Now, make a new project and click Project, Components. Click browse, go to the directory where the file is. Double click on the file and click OK. Draw the control onto the form and look at the properties. See, it works!
More for Developers
On the Codeguru Forums
Visit the Forums »Featured Partner Resources
Get your Android Apps ready for Intel® Atom™ processor-based smartphones and tablets now.
Use the Android NDK to deliver the best performance on Intel® Atom™ processor-based devices.
The Android community on the Intel® Software Network has everything you need to prepare your apps for Intel® Atom™ processor-based devices.



Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.