Wrapper Class

Wrapper Class

Question:
In VB4, how do I create a wrapper class for a textbox?I want to be able to add properties to a textbox.

Answer:
There are many approaches you can take to this. Typically, you’ll want to expose a Client property of the class, to which you’ll assign the textbox. It may look something like this: 

Private m_txt As TextBoxPublic Property Set Client(NewObj As Object)   ‘   ‘ Set new TextBox as Client property.   ‘   If TypeName(NewObj) = “TextBox” Then      Set m_txt = NewObj   Else      ‘ Raise error #13 –> Type Mismatch      Err.Raise Number:=13, _         Source:=”CMyClass.Client”, _         Description:=”Client property must be of type TextBox.”   End IfEnd PropertyPublic Property Get Client() As Object   ‘   ‘ Return TextBox as Client property.   ‘   Set Client = m_txtEnd Property
 You’ll then have a reference to the textbox and can do with it what you will. See my columns in the January and March 1996 issues of VBPJ for examples of doing this with Listbox and Picture box controls.

 Users of VB5 will want to take a look at the possibilities opened up by declaring the class reference to the textbox using WithEvents! Using this new feature allows your class to recieve all events the the host form normally does, thus greatly reducing the amount of code required in VB4 to notify the class of control events.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes